如何使用css3使循环动画等待

Cih*_*han 8 css css3 css-animations


我有一个带有以下内容的css3动画:

@-webkit-keyframes rotate {
    from {
    -webkit-transform: rotate(0deg);
    }
    to { 
    -webkit-transform: rotate(360deg);
    }
}

.animated {
-webkit-animation-name: rotate;
-webkit-animation-duration: 2.4s;
-webkit-animation-iteration-count: infinite;
-webkit-transition-timing-function: ease-in-out;
}
Run Code Online (Sandbox Code Playgroud)

它完美无瑕,好吧......,我想让它在循环之间等待:
动画启动,动画完成,等待(约0.5秒),动画启动,动画结束,等待(约0.5秒) ......

PS:我试过-webkit-animation-delay,它不起作用.

有帮助吗?

Chr*_*ris 24

在动画持续时间内添加0.5秒,然后在您的动画中创建一个额外的帧,keyframes不会改变旋转量;

@-webkit-keyframes rotate {
    0% {
    -webkit-transform: rotate(0deg);
    }
    83% { /*2.4 / 2.9 = 0.827*/
    -webkit-transform: rotate(360deg);
    }
    100% {
    -webkit-transform: rotate(360deg);
    }
}
.animated {
...
-webkit-animation-duration: 2.9s; /*note the increase*/
...
}
Run Code Online (Sandbox Code Playgroud)

小演示:小链接.

  • 对Abody97所做的一点"解决方法":[webkit动画小提琴](http://jsfiddle.net/ZVgAu/1/) (2认同)