CSS动画延迟之间循环 [英] CSS Animation Delay in Between Loop
本文介绍了CSS动画延迟之间循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试获取带有价格的标签向上滑动,然后使用CSS向下滑动。
Trying to get a label with class price to slide up, then slide back down with CSS.
我有以下 -
-webkit-animation-name: slidingPrice;
-webkit-animation-duration: 300ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-delay: 4s;
@-webkit-keyframes slidingPrice {
0% { opacity: 0; bottom: -30px; }
50% { opacity: 1; bottom: 0; }
100% { opacity: 0; bottom: -30px; }
}
我看到动画在4秒内开始, ,只是以快速的方式不断循环。
I am seeing that the animation starts in 4 seconds, but once it starts, just continuously loops in a fast manner. How would I add a 4 second delay in between each loop and stop for a 2 seconds at the 50% mark?
推荐答案
如何在每个循环之间添加4秒的延迟,并在50%
Make your loop longer and add more keyframes.
@-webkit-keyframes slidingPrice {
0% { opacity: 0; bottom: -30px; } /* 0ms initial values */
2.38% { opacity: 1; bottom: 0; } /* 150ms half of animation */
34.13% { opacity: 1; bottom: 0; } /* 2150ms still at half of animation */
36.51% { opacity: 0; bottom: -30px; } /* 2300ms back to initial */
100% { opacity: 0; bottom: -30px; } /* 6300ms still at initial */
}
.price {
-webkit-animation-name: slidingPrice;
-webkit-animation-duration: 6300ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-delay: 4s;
}
这篇关于CSS动画延迟之间循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文