CSS Property animation-iteration-count








The animation-iteration-count property defines how many times to play the animation.

Summary

Initial value
1
Inherited
no
CSS Version
CSS3
JavaScript syntax
object.style.animationIterationCount="infinite"
Animatable
no

CSS Syntax

animation-iteration-count: number|infinite;

Property Values

number
how many times to play the animation. Default value is 1
infinite
play the animation for ever

Browser compatibility

animation-iteration-count 4.0 -webkit- 10.0 16.0 (5.0 -moz-) 4.0 -webkit- 15.0 -webkit-(12.0 -o-)




Example

<!DOCTYPE html>
<html>
<head>
<style> 
div {<!-- w w w  .jav  a 2s .  co m-->
    width: 100px;
    height: 100px;
    background: black;
    position: relative;
    -webkit-animation: mymove 3s;  /* Chrome, Safari, Opera */
    -webkit-animation-iteration-count: 2;  /* Chrome, Safari, Opera */
    animation: mymove 3s;
    animation-iteration-count: 2;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes mymove {
    from {top: 0px;}
    to {top: 200px;}
}

@keyframes mymove {
    from {top: 0px;}
    to {top: 200px;}
}
</style>
</head>
<body>

<div></div>

</body>
</html>

Click to view the demo