animation-iteration-count
animation-iteration-count规定动画被播放的次数。默认是 1。
语法
animation-iteration-count: infinite; animation-iteration-count: 3; animation-iteration-count: 2.3; animation-iteration-count: 2, 0, infinite;
值
值 | 描述 |
---|---|
infinite | 无限循环播放动画 |
<number> | 动画播放次数,不可为负数。 |
例子
HTML
<div class="stage"> <figure class="ball"></figure> </div>
CSS
@keyframes 'slide' { from { left: 0; top: 0; } 50% { left: 244px; top: 100px; } to { left: 488px; top: 0; } } .stage { height: 150px; position: relative; min-width: 538px; } .stage .ball { animation-name: slide; animation-duration:2s; animation-timing-function: ease-in-out; animation-delay: 1.5s; animation-iteration-count: infinite;//无线循环播放动画。 animation-direction: alternate; } .ball { background: red; border-radius: 50%; height: 50px; position: absolute; width: 50px; }
执行结果