CSS3 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

CSS Syntax
animation-direction: normal|reverse|alternate|alternate-reverse|initial|inherit;
Property Values
Value Description Play it
normal Default value. The animation is played as normal (forwards) #myDIV {
animation-direction:normal;
}
reverse The animation is played in reverse direction (backwards) #myDIV {
animation-direction:reverse ;
}
alternate The animation is played forwards first, then backwards #myDIV {
animation-direction:alternate ;
}
alternate-reverse The animation is played backwards first, then forwards #myDIV {
animation-direction:alternate-reverse;
}
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit
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 »

Post Author: Zahid Farid