I’m trying to make a simple text animation with CSS.
The text should slowly change value of font-style attribute.
I have tried something like this:
h1 {
animation-duration: 3s;
animation-name: slidein;
}
@keyframes slidein {
from {
font-style: oblique 30deg;
}
to {
font-style: oblique 0deg;
}
}
2
Answers
We can’t animate the
font-style
property. Instead, we can mimic the same with skewing, like so:And
font-style
can’t have adeg
value, afaik…Provided, you’re using a variable font including a
slant
design axis you can interpolate between different slanting angles:Some browsers may not support transitions/animations for the
font-style
property. Apparently, animating thefont-variation-settings
property currently supports the best cross browser compatibility (Firefox, Chromium, Webkit/safari.Keep in mind font animations are not well optimized compared to CSS transformations – so the transform/skew approach may be a more performant alternative.