animation-direction

  • Revision slug: CSS/animation-direction
  • Revision title: animation-direction
  • Revision id: 22229
  • Created:
  • Creator: JaredWein
  • Is current revision? No
  • Comment 1 words added, 1 words removed

Revision Content

{{ CSSRef() }}

{{ SeeCompatTable() }}

Summary

The animation-direction CSS property indicates whether the animation should play in reverse on alternate cycles.

It is often convenient to use the shorthand property {{ cssxref("animation") }} to set all animation properties at once.

<style type="text/css"></style>
  • {{ Xref_cssinitial() }}: normal
  • Applies to: all elements, and {{ cssxref("::before") }} and {{ cssxref("::after") }} pseudo-elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

animation-direction: normal | alternate [, normal | alternate]*

Values

normal
The animation should play forward each cycle. In other words, each time the animation cycles, the animation will reset to the beginning state and start over again. This is the default animation direction setting.
alternate
The animation should reverse direction each cycle. When playing in reverse, the animation steps are performed backward. In addition, timing functions are also reversed; for example, an ease-in animation is replaced with an ease-out animation when played in reverse.
reverse
The animation plays backward each cycle. Each time the animation cycles, the animation resets to the end state and start over again.
alternate-reverse
The animation plays backward on the first play-through, then forward on the next, then continues to alternate.

Examples

See CSS animations for examples.

Specifications

Specification Status Comment
CSS Animations Level 3 {{ Spec2('CSS3 Animations') }} For the two new values, see the W3C discussion.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatVersionUnknown() }}{{ property_prefix("-webkit") }} {{ CompatGeckoDesktop("5.0") }}{{ property_prefix("-moz") }} 10 {{ property_prefix("-ms") }} 12{{ property_prefix("-o") }} 4.0{{ property_prefix("-webkit") }}
reverse 19 {{ property_prefix("-webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
alternate-reverse 19 {{ property_prefix("-webkit") }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }} {{ CompatNo() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

  • CSS animations
  • {{ domxref("Event/AnimationEvent", "AnimationEvent") }}
  • {{ CSS_Reference:animation() }}

{{ languages( { "ja": "ja/CSS/animation-direction", "fr": "fr/CSS/animation-direction"} ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ SeeCompatTable() }}</p>
<h2>Summary</h2>
<p>The <code>animation-direction</code> CSS property indicates whether the animation should play in reverse on alternate cycles.</p>
<p>It is often convenient to use the shorthand property {{ cssxref("animation") }} to set all animation properties at once.</p>
<nobr>
<style type="text/css"><![CDATA[.cssprop {
  display:table;
  padding: 0.4em;
  border-left:0.15em solid;
  background-color:#eeeeff
}
.cssprop li {
 display:table-row;
 padding: 3px;
 margin:0;
}
.cssprop li dfn {
  display:table-cell;
  padding: 0 5px;
  border-bottom: none;
  cursor:inherit;
}


]]></style>
<ul class="cssprop"> <li><dfn>{{ Xref_cssinitial() }}:</dfn> <code>normal</code></li> <li><dfn>Applies to:</dfn> all elements, and {{ cssxref("::before") }} and {{ cssxref("::after") }} pseudo-elements</li> <li><dfn>{{ Xref_cssinherited() }}:</dfn> no</li> <li><dfn>Media:</dfn> {{ Xref_cssvisual() }}</li> <li><dfn>{{ Xref_csscomputed() }}:</dfn> as specified</li>
</ul>
</nobr>
<p><nobr></nobr></p><h2><nobr>Syntax</nobr></h2><nobr>
<pre class="eval syntaxbox">animation-direction: normal | alternate [, normal | alternate]*
</pre>
<h3>Values</h3>
<dl> <dt><code>normal</code></dt> <dd>The animation should play forward each cycle. In other words, each time the animation cycles, the animation will reset to the beginning state and start over again. This is the default animation direction setting.</dd> <dt><code>alternate</code></dt> <dd>The animation should reverse direction each cycle. When playing in reverse, the animation steps are performed backward. In addition, timing functions are also reversed; for example, an <code>ease-in</code> animation is replaced with an <code>ease-out</code> animation when played in reverse.</dd> <dt><code>reverse</code></dt> <dd>The animation plays backward each cycle. Each time the animation cycles, the animation resets to the end state and start over again.</dd> <dt><code>alternate-reverse</code></dt> <dd>The animation plays backward on the first play-through, then forward on the next, then continues to alternate.</dd>
</dl><h2>Examples</h2>
<p>See <a href="/en/CSS/CSS_animations" title="en/CSS/CSS_animations">CSS animations</a> for examples.</p>
<h2>Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://dev.w3.org/csswg/css3-animations/#the-animation-direction-property-" title="http://dev.w3.org/csswg/css3-animations/#the-animation-shorthand-property-">CSS Animations Level 3</a></td> <td>{{ Spec2('CSS3 Animations') }}</td> <td>For the two new values, see the <a class="external" href="http://lists.w3.org/Archives/Public/www-style/2011May/0090.html">W3C discussion</a>.</td> </tr> </tbody>
</table>
<h2 name="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() }}{{ property_prefix("-webkit") }}</td> <td>{{ CompatGeckoDesktop("5.0") }}{{ property_prefix("-moz") }}</td> <td>10 {{ property_prefix("-ms") }} <a class="external" href="http://msdn.microsoft.com/en-us/ie/hh272902#_CSSAnimations" title="http://msdn.microsoft.com/en-us/ie/hh272902#_CSSAnimations"></a></td> <td>12{{ property_prefix("-o") }}</td> <td>4.0{{ property_prefix("-webkit") }}</td> </tr> <tr> <td><code>reverse</code></td> <td>19 {{ property_prefix("-webkit") }}<a class="link-https" href="https://bugs.webkit.org/show_bug.cgi?id=60525" title="https://bugs.webkit.org/show_bug.cgi?id=60525"></a></td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> <tr> <td><code>alternate-reverse</code></td> <td>19 {{ property_prefix("-webkit") }}<a class="link-https" href="https://bugs.webkit.org/show_bug.cgi?id=60525" title="https://bugs.webkit.org/show_bug.cgi?id=60525"></a></td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> <td>{{ CompatNo() }}</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Chrome for Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<h2>See also</h2>
<ul> <li><a href="/en/CSS/CSS_animations" title="en/CSS/CSS_animations">CSS animations</a></li> <li>{{ domxref("Event/AnimationEvent", "AnimationEvent") }}</li> <li>{{ CSS_Reference:animation() }}</li>
</ul>
<p>{{ languages( { "ja": "ja/CSS/animation-direction", "fr": "fr/CSS/animation-direction"} ) }}</p></nobr>
Revert to this revision