This effect creates an animated gradient text using CSS background-clip: text. The gradient smoothly flows through multiple rainbow colors, creating a vibrant animated effect.
The technique uses a large gradient background that moves behind the text, creating the illusion of the colors flowing through the letters. By setting background-size to 200%, we create extra gradient space that can be animated by shifting background-position.
<h1>Animated text gradient</h1>html, body {
height: 100%;
}
h1 {
font-size: 3em;
}
body {
background: #0a0a0a;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-family: "Rubik", sans-serif;
}
:root {
--color1: #FF9999;
--color2: #FFB366;
--color3: #FFFF99;
--color4: #99FF99;
--color5: #99CCFF;
--color6: #B399CC;
--color7: #CC99FF;
}
@keyframes gradient-animation {
from {
background-position: 200% center;
}
to {
background-position: 0 center;
}
}
h1 {
background: linear-gradient(
to right,
var(--color1),
var(--color2),
var(--color3),
var(--color4),
var(--color5),
var(--color6),
var(--color7),
var(--color1)
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: gradient-animation 3s linear infinite;
background-size: 200%;
}background-clip: text clips the gradient to the text shape-webkit-text-fill-color: transparent makes the text transparent to show the gradientbackground-position from 200% to 0 for continuous flowing effectThis effect works in all modern browsers. For older browsers, the text will simply display in a solid color.
Watch the YouTube Short for a step-by-step guide on how to create this animation.