Home >Web Front-end >Front-end Q&A >Can css3 only implement animation once?
css3 can not only implement animation once; you can use the "animation-iteration-count" attribute to define the number of animation playback times. When the attribute value is set to infinite, the number of playback times is unlimited, and the syntax is "animation- iteration-count:play count".
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
css3 can only achieve one animation.
Just use animation-iteration-count.
The animation-iteration-count property defines how many times the animation should play. The default value is one.
Syntax
animation-iteration-count: value;
n A number that defines how many times the animation should be played
infinite Specifies that the animation should be played an infinite number of times ( Forever)
Examples are as follows:
<html> <head> <meta charset="utf-8"> <title>123</title> <style> div { width:100px; height:100px; background:red; position:relative; animation:mymove 3s; animation-iteration-count:3; /* Safari and Chrome */ -webkit-animation:mymove 3s; -webkit-animation-iteration-count:3; } @keyframes mymove { from {top:0px;} to {top:200px;} } @-webkit-keyframes mymove /* Safari and Chrome */ { from {top:0px;} to {top:200px;} } </style> </head> <body> <p><strong>注意:</strong> Internet Explorer 9 及更早 IE 版本浏览器不支持 animation-iteration-count 属性。</p> <div></div> </body> </html>
Output results:
(Learning video sharing: css video tutorial)
The above is the detailed content of Can css3 only implement animation once?. For more information, please follow other related articles on the PHP Chinese website!