files/en-us/web/api/csskeyframesrule/index.md
{{APIRef("CSSOM")}}
The CSSKeyframesRule interface describes an object representing a complete set of keyframes for a CSS animation. It corresponds to the contents of a whole {{cssxref("@keyframes")}} at-rule.
{{InheritanceDiagram}}
Inherits properties from its ancestor {{domxref("CSSRule")}}.
Inherits methods from its ancestor {{domxref("CSSRule")}}.
SYNTAX_ERR is thrown.0% and 100%.0% and 100%. If no such keyframe exists, findRule returns null.The CSS includes a keyframes at-rule. This will be the first {{domxref("CSSRule")}} returned by document.styleSheets[0].cssRules.
myRules[0] returns a CSSKeyframesRule object.
@keyframes slide-in {
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
}
const myRules = document.styleSheets[0].cssRules;
const keyframes = myRules[0]; // a CSSKeyframesRule
CSSKeyframesRule can be indexed like an array, and functions similar to its {{domxref("CSSKeyframesRule.cssRules", "cssRules")}} property.
const keyframes = document.styleSheets[0].cssRules[0];
for (let i = 0; i < keyframes.length; i++) {
console.log(keyframes[i].keyText);
}
// Output:
// 0%
// 100%
{{Specifications}}
{{Compat}}