I'm trying to do a text reveal CSS animation like this one. Using ::before
and ::after
seems like an overly complicated approach so I'm trying to do this using a linear-gradient background color, background position, or something else that could be simpler.
:root {
--primary-rgba: rgba(17,184,106,1);
--secondary-rgba: rgba(255,255,255,1);
}
@keyframes slidein {
0% {
background: transparent;
}
25% {
background: linear-gradient(90deg, var(--secondary-rgba) 0%, var(--secondary-rgba) 50%, var(--primary-rgba) 50% var(--primary-rgba) 100%);
}
50% {
background: var(--secondary-hex);
}
75% {
background: linear-gradient(90deg, var(--primary-rgba) 0%, var(--primary-rgba) 50%, var(--secondary-rgba) 50% var(--secondary-rgba) 100%);
}
100% {
background: transparent;
}
}
I even wondered if adding more frames to the animation would make it work the way I wanted to and tried hacking in a bunch of (repetative) frames. Still no luck.
After finding out that CSS transitions likely don't support gradients yet, I tried using background position to reveal text but with no success.
Are either of these approaches doable?