We have this sort of syntax for defining key frames in a css file:
@-webkit-keyframes fade {
from {opacity: 1;}
to {opacity: 0.25;}
}
and we reference it like:
.foo {
-webkit-animation: fade 1s linear infinite;
}
is there a way to just inline it, like:
.foo {
-webkit-animation: (from {opacity: 1;} to {opacity: 0.25;}) 1s linear infinite;
}
Is there a way to do that, or to inject a “@-webkit-keyframes” element into my stylesheet at runtime?
Thanks
Taking a look at the W3C CSS Animations WD, the syntax for the
animationshorthand property is:Meaning it takes only the
animation-namewhich is used to select the keyframe at-rule that provides the property values for the animation, followed by the other parameters which define how these rules should be executed.There’s currently no shorthand syntax defined in the specs that would allow for defining an inline keyframe at-rule, you have to reference an existing one using the
animation-nameproperty. From the specs: