CSS keyframe animations and delay?

邮差的信 提交于 2019-12-24 11:35:38

问题


I have a keyframe animation, that infinitly loops.

-webkit-animation: fade 3s ease-in-out infinite;

@-webkit-keyframes fade {
0% { opacity: 0; -webkit-transform: rotate(0deg);}
20% { opacity: 1; -webkit-transform: rotate(360deg);}
100% { opacity: 0; -webkit-transform: rotate(360deg);}
}

How can I delay each ilteration of the loop. im aware I can delay teh entire animation, but this only occurs once. I wish to do it everytime.


回答1:


Unfortunately there is no current option to easily put a delay between the iterations, but instead you can add another stop with the same values (as I commented), and increase the duration:

@keyframes fade {
    0% { opacity: 0; transform: rotate(0deg); }
    10% { opacity: 1; transform: rotate(360deg); }
    50% { opacity: 0; transform: rotate(360deg); }
    100% { opacity: 0; transform: rotate(360deg); }
}

.selector {
    animation: fade 6s ease-in-out infinite; /* increased duration */
}

Demo at http://jsfiddle.net/PW8Ur/2/

If you need scripted control over when you want to restart an animation, you could have a look at: http://css-tricks.com/restart-css-animation/



来源:https://stackoverflow.com/questions/20499462/css-keyframe-animations-and-delay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!