CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES

CSS3 animation-iteration-count Property

Topic: CSS3 Properties ReferencePrev|Next

Description

The animation-iteration-count CSS property specifies the number of times an animation cycle should be played before stopping.

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

Default value: 1
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-iteration-count: 
number | infinite | initial | inherit

The example below shows the animation-iteration-count 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: infinite;
    /* Standard syntax */
    animation-name: moveit;
    animation-duration: 4s;
    animation-iteration-count: infinite;
}
 
/* 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
number Specifies the number of times an animation should repeat. Default value is 1. Negative values are not allowed.
infinite The animation will repeat forever i.e. infinite times.
initial Sets this property to its default value.
inherit If specified, the associated element takes the computed value of its parent element animation-iteration-count property.

Note: You may specify non-integer values like 0.5, 0.75 etc. to play just a part of an animation cycle, for example the value 0.5 will play half of the animation cycle.


Browser Compatibility

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

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