animation-iteration-count: number | infinite [, number | infinite]*
|
<!DOCTYPE html>
<html> <style type="text/css"> @-webkit-keyframes resize { from { height: 300px; width: 100px; left: 0; top: 0; } 50% { height: 100px; width: 100px; left: 300px; top: 0; } to { height: 100px; width: 300px; left: 300px; top: 300px; } } @-webkit-keyframes move { from { left: 150px; top: 150px; } 50% { left: 300px; top: 0; } to { left: 400px; top: 200px; } } #anim1 { -webkit-animation-name: resize; -webkit-animation-duration: 4s; -webkit-animation-iteration-count: infinite; position: absolute; background-color: purple; } #anim2 { -webkit-animation-name: move; -webkit-animation-duration: 4s; -webkit-animation-iteration-count: 2; position: absolute; top: 150px; left: 150px; background-color: orange; } </style> <body> <div id="anim1">Watch me move and change size forever!</div> <div id="anim2">Watch me move two times</div> </body> </html> |
Note -
• WebKit supports this property as -webkit-animation-iteration-count. • Firefox 3.7 pre-releases show support for CSS transitions which are very related to CSS animation. It is quite likely that a form of this property using the -moz prefix may be supported in a Firefox browser by the time you read this. |