Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 850017 of CSSKeyframesRule

  • Revision slug: Web/API/CSSKeyframesRule
  • Revision title: CSSKeyframesRule
  • Revision id: 850017
  • Created:
  • Creator: Sebastianz
  • Is current revision? No
  • Comment Fixed typo in browser compatibility table

Revision Content

{{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 and 1.
{{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 and 1. If no such keyframe exists, findRule returns null.

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}}[3] {{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")}}

Revision Source

<p>{{APIRef("CSSOM")}}</p>

<p>{{SeeCompatTable}}</p>

<p>The <strong><code>CSSKeyframesRule</code></strong> interface describes an object representing a complete set of keyframes for a CSS animation. It corresponds to the contains of a whole {{cssxref("@keyframes")}} <a href="/en-US/docs/CSS/At-rule">at-rule</a>. It implements the {{domxref("CSSRule")}} interface with a type value of <code>7</code> (<code>CSSRule.KEYFRAMES_RULE</code>).</p>

<h2 id="Syntax">Syntax</h2>

<p>The syntax is described using the <a href="https://dev.w3.org/2006/webapi/WebIDL/">WebIDL</a> format.</p>

<pre class="syntaxbox">
interface CSSKeyframesRule : CSSRule {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attribute DOMString&nbsp;&nbsp; name;
&nbsp; readonly attribute CSSRuleList cssRules;

&nbsp; void&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appendRule(in DOMString rule);
&nbsp; void&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; deleteRule(in DOMString key);
&nbsp; CSSKeyframeRule findRule(in DOMString key);
};
</pre>

<h2 id="Properties">Properties</h2>

<p>As a {{domxref("CSSRule")}}, <code>CSSKeyframesRule</code> also implements the properties of these interfaces. It has two properties :</p>

<dl>
 <dt>{{domxref("CSSPageRule.name")}}</dt>
 <dd>Represents the name of the animation, used by the {{cssxref("animation-name")}} property.</dd>
 <dt id="cssRules">{{domxref("CSSPageRule.cssRules")}} {{readOnlyInline}}</dt>
 <dd>Returns a {{domxref("CSSRuleList")}} of the CSS rules in the media rule.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p>As a {{domxref("CSSRule")}}, <code>CSSKeyframesRule</code> also implements the methods of that interface. It has three specific methods:</p>

<dl>
 <dt id="appendRule">{{domxref("CSSPageRule.appendRule")}}</dt>
 <dd>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 <code>SYNTAX_ERR</code> is thrown.</dd>
 <dt id="deleteRule">{{domxref("CSSPageRule.deleteRule")}}</dt>
 <dd>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 <code>0</code> and <code>1</code>.</dd>
 <dt>{{domxref("CSSPageRule.findRule")}}</dt>
 <dd>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 <code>0</code> and <code>1</code>. If no such keyframe exists, <code>findRule</code> returns <code>null</code>.</dd>
</dl>

<h2 id="Specification">Specification</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Animations', '#interface-csskeyframesrule', 'CSSKeyframesRule')}}</td>
   <td>{{Spec2('CSS3 Animations')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("5.0")}}</td>
   <td>10</td>
   <td>12 {{property_prefix("-o")}}<br />
    12.10</td>
   <td>4.0</td>
  </tr>
  <tr>
   <td><code>appendRule</code></td>
   <td>{{CompatVersionUnknown}}[1]</td>
   <td>{{CompatGeckoDesktop("5.0")}}[2]<br />
    {{CompatGeckoDesktop("22.0")}}</td>
   <td>10[3]</td>
   <td>{{CompatVersionUnknown}}[3]</td>
   <td>{{CompatVersionUnknown}}[3]</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE&nbsp;Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("5.0")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>12 {{property_prefix("-o")}}<br />
    12.10</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>appendRule</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}[3]</td>
   <td>{{CompatGeckoMobile("5.0")}}[2]<br />
    {{CompatGeckoMobile("22.0")}}</td>
   <td>{{CompatVersionUnknown}}[3]</td>
   <td>{{CompatVersionUnknown}}[3]</td>
   <td>{{CompatVersionUnknown}}[3]</td>
   <td>{{CompatVersionUnknown}}[1]</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] The non-standard name <code>insertRule</code> was removed in {{CompatChrome(45.0)}}.</p>

<p>[2] Gecko 5.0 implemented this with the non-standard name <code>insertRule</code>. In Gecko 22.0 it was changed to the standard name <code>appendRule</code>.</p>

<p>[3] Internet Explorer 10 and Opera implement this with the non-standard name <code>insertRule</code>.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{CSSOM}}</li>
 <li>{{cssxref("@keyframes")}}</li>
</ul>
Revert to this revision