CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

CSS3 animation-fill-mode Property

Topic: CSS3 Properties ReferencePrev|Next

Description

The animation-fill-mode CSS property specifies how a CSS animation should apply styles to its target before and after it is executing.

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

Default value: none
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-fill-mode: 
none | forwards | backwards | both | initial | inherit

The example below shows the animation-fill-mode 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-fill-mode: forwards;
    /* Standard syntax */
    animation-name: moveit;
    animation-duration: 4s;
    animation-fill-mode: forwards;
}
 
/* Chrome, Safari, Opera */
@-webkit-keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}
 
/* Standard syntax */
@keyframes moveit {
    from {left: 0;}
    to {left: 50%;}
}

Property Values

The following table describes the values of this property.

Value Description
none The animation will not apply any styles to the target before or after it is executing.
forwards After the animation ends (as determined by its animation-iteration-count), the animation will apply the property values for the time the animation ended.
backwards The animation will apply the property values defined in the keyframe that will start the first iteration of the animation, during the period defined by animation-delay property. These are either the values of the from keyframe (when animation-direction is normal or alternate) or those of the to keyframe (when animation-direction is reverse or alternate-reverse).
both The animation will follow the rules for both forwards and backwards, thus extending the animation properties in both directions.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-fill-mode property.

Browser Compatibility

The animation-fill-mode 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-duration, animation-timing-function, animation-delay, animation-iteration-count, animation-direction, animation-play-state, @keyframes.

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