CSS animation-direction Property


Example

Play the animation forwards first, then backwards:

div {
  animation-direction: alternate;
}
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The animation-direction property defines whether an animation should be played forwards, backwards or in alternate cycles.

Default value: normal
Inherited: no
Animatable: no. Read about animatable
Version: CSS3
JavaScript syntax: object.style.animationDirection="reverse" Try it

Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Numbers followed by -webkit-, -moz-, or -o- specify the first version that worked with a prefix.

Property
animation-direction 43.0
4.0 -webkit-
10.0 16.0
5.0 -moz-
9.0
4.0 -webkit-
30.0
15.0 -webkit-
12.0 -o-


CSS Syntax

animation-direction: normal|reverse|alternate|alternate-reverse|initial|inherit;

Property Values

Value Description Demo
normal Default value. The animation is played as normal (forwards) Play it »
reverse The animation is played in reverse direction (backwards) Play it »
alternate The animation is played forwards first, then backwards Play it »
alternate-reverse The animation is played backwards first, then forwards Play it »
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit

More Examples

Example

Play the animation backwards first, then forwards:

div {
  animation-direction: alternate-reverse;
}
Try it Yourself »

Example

Play the animation backwards:

div {
  animation-direction: reverse;
}
Try it Yourself »

Related Pages

CSS tutorial: CSS Animations

HTML DOM reference: animationDirection property


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.