Dark CSS

Gradient Text Animation using CSS

Facebook
Twitter
WhatsApp

code preview

html code

				
					<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Text Gradient Effect</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <h1 data-text="Hello Dark CSS" class="text">
    Hello Dark CSS
 </h1>
</body>

</html>
				
			

css code

				
					@import url('https://fonts.googleapis.com/css2?family=Dangrek&display=swap');

* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

html,
body {
    display: grid;
    height: 100%;
    place-items: center;
    background: #212121;
}

.text {
    display: inline-block;
    position: relative;
    font-size: 2.5rem;
    font-family: "Dangrek", serif;
    cursor: pointer;
    color: #e8e8e8;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.text::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    color: transparent;
    background: linear-gradient(to right,
            #ff00ff, #00ffff);
    background-clip: text;
    transition: width 0.3s;
}

.text:hover::before {
    width: 100%;
}