{{APIRef("CSSOM")}}
{{SeeCompatTable}}
The CSSKeyframesRule
interface describes an object representing a complete set of keyframes for a CSS animation. It corresponds to the contains of a whole {{cssxref("@keyframes")}} at-rule. It implements the {{domxref("CSSRule")}} interface with a type value of 7
(CSSRule.KEYFRAMES_RULE
).
Syntax
The syntax is described using the WebIDL format.
interface CSSKeyframesRule : CSSRule { attribute DOMString name; readonly attribute CSSRuleList cssRules; void appendRule(in DOMString rule); void deleteRule(in DOMString key); CSSKeyframeRule findRule(in DOMString key); };
Properties
As a {{domxref("CSSRule")}}, CSSKeyframesRule
also implements the properties of these interfaces. It has two properties :
- {{domxref("CSSPageRule.name")}}
- Represents the name of the animation, used by the {{cssxref("animation-name")}} property.
- {{domxref("CSSPageRule.cssRules")}} {{readOnlyInline}}
- Returns a {{domxref("CSSRuleList")}} of the CSS rules in the media rule.
Methods
As a {{domxref("CSSRule")}}, CSSKeyframesRule
also implements the methods of that interface. It has three specific methods:
- {{domxref("CSSPageRule.appendRule")}}
- Inserts a new keyframe rule into the current CSSKeyframesRule. The parameter is a {{domxref("DOMString")}} containing a keyframe in the same format as an entry of a {{cssxref("@keyframes")}} at-rule. If it contains more than one keyframe rule, a {{domxref("DOMException")}} with a
SYNTAX_ERR
is thrown. - {{domxref("CSSPageRule.deleteRule")}}
- Deletes a keyframe rule from the current CSSKeyframesRule. The parameter is the index of the keyframe to be deleted, expressed as a {{domxref("DOMString")}} resolving as a number between
0
and1
. - {{domxref("CSSPageRule.findRule")}}
- Returns a keyframe rule corresponding to the given key. The key is a {{domxref("DOMString")}} containing an index of the keyframe to be returned, resolving to a number between
0
and1
. If no such keyframe exists,findRule
returnsnull
.
Specification
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS3 Animations', '#interface-csskeyframesrule', 'CSSKeyframesRule')}} | {{Spec2('CSS3 Animations')}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("5.0")}} | 10 | 12 {{property_prefix("-o")}} 12.10 |
4.0 |
appendRule |
{{CompatVersionUnknown}}[1] | {{CompatGeckoDesktop("5.0")}}[2] {{CompatGeckoDesktop("22.0")}} |
10[3] | {{CompatVersionUnknown}}[3] | {{CompatVersionUnknown}}[3] |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("5.0")}} | {{CompatVersionUnknown}} | 12 {{property_prefix("-o")}} 12.10 |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
appendRule |
{{CompatUnknown}} | {{CompatVersionUnknown}}[1] | {{CompatGeckoMobile("5.0")}}[2] {{CompatGeckoMobile("22.0")}} |
{{CompatVersionUnknown}}[3] | {{CompatVersionUnknown}}[3] | {{CompatVersionUnknown}}[3] | {{CompatVersionUnknown}}[1] |
[1] The non-standard name insertRule
was removed in {{CompatChrome(45.0)}}.
[2] Gecko 5.0 implemented this with the non-standard name insertRule
. In Gecko 22.0 it was changed to the standard name appendRule
.
[3] Internet Explorer 10 and Opera implement this with the non-standard name insertRule
.
See also
- {{CSSOM}}
- {{cssxref("@keyframes")}}