CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

CSS3 animation-direction Property

Topic: CSS3 Properties ReferencePrev|Next

Description

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

The following table summarizes the usages context and the version history of this property.

Default value: normal
Applies to: All elements, ::before and ::after pseudo-elements
Inherited: No
Animatable: No. See animatable properties.
Version: New in CSS3

Syntax

The syntax of the property is given with:

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

The example below shows the animation-direction property in action.

.box {
    width: 50px;
    height: 50px;
    background: red;
    position: relative;
    /* Chrome, Safari, Opera */
    -webkit-animation-name: moveit;
    -webkit-animation-duration: 4s;
    -webkit-animation-iteration-count: 2;
    -webkit-animation-direction: alternate;
    /* Standard syntax */
    animation-name: moveit;
    animation-duration: 4s;
    animation-iteration-count: 2;
    animation-direction: alternate;
}
 
/* Chrome, Safari, Opera */
@-webkit-keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}
 
/* Standard syntax */
@keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}

Note: The animation-direction property has no effect if the animation is set to play only once, see animation-iteration-count property.


Property Values

The following table describes the values of this property.

Value Description
normal The animation should play forward in each cycle. This is default.
reverse The animation should play backward in each cycle.
alternate The animation plays forward in the first cycle, then play backward, then continues to alternate.
alternate-reverse The animation plays backward in the first cycle, then play forward, then continues to alternate.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-direction property.

Browser Compatibility

The animation-direction property is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 5+ -moz-, 15+
  • Google Chrome 4+ -webkit-
  • Internet Explorer 10+
  • Apple Safari 4+ -webkit-
  • Opera 12+ -o-, 15+ -webkit-

Further Reading

See tutorial on: CSS3 Animations.

Related properties and at-rules: animation, animation-name, animation-delay, animation-timing-function, animation-iteration-count, animation-direction, animation-fill-mode, animation-play-state, @keyframes.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties