CSSKeyframeRule
The CSSKeyframeRule interface describes an object representing a set of styles for a given keyframe. It corresponds to the contents of a single keyframe of a @keyframes at-rule.
Properties
Inherits properties from its ancestor CSSRule.
CSSKeyframeRule.keyText-
Represents the key of the keyframe, like
'10%','75%'. Thefromkeyword maps to'0%'and thetokeyword maps to'100%'. CSSKeyframeRule.styleRead only-
Returns a
CSSStyleDeclarationof the CSS style associated with the keyframe.
Methods
No specific methods; inherits methods from its ancestor CSSRule.
Examples
The CSS includes a keyframes at-rule. This will be the first CSSRule returned by document.styleSheets[0].cssRules.
myRules[0] returns a CSSKeyframesRule object, which will contain individual CSSKeyFrame objects for each keyframe.
@keyframes slidein {
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
}
let myRules = document.styleSheets[0].cssRules;
let keyframes = myRules[0]; // a CSSKeyframesRule
console.log(keyframes[0]); // a CSSKeyframeRule representing an individual keyframe.
Specifications
| Specification |
|---|
| CSS Animations Level 2 # interface-csskeyframerule |
Browser compatibility
BCD tables only load in the browser