我试图发挥不同的css动画一个接一个,但我不知道如何。
基本上我想做的是播放一个动画,在屏幕上显示15秒,然后播放下一个,显示15秒,然后再播放下一个,当最后一个播放完后,它应该从顶部重新开始。
这里有一个例子,它应该播放第一个,显示15秒,然后移动到下一个,做同样的事情。
<style> #animated-example {
width: 300px;
height: 200px;
border: solid 1px #1A7404;
position: absolute;
background-color: #62A80A;
}
.animated {
-webkit-animation-duration: 2s;
animation-duration: 2s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes bounceInLeft {
0% {
opacity: 0;
-webkit-transform: translateX(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateX(30px);
}
80% {
-webkit-transform: translateX(-10px);
}
100% {
-webkit-transform: translateX(0);
}
}
@keyframes bounceInLeft {
0% {
opacity: 0;
transform: translateX(-2000px);
}
60% {
opacity: 1;
transform: translateX(30px);
}
80% {
transform: translateX(-10px);
}
100% {
transform: translateX(0);
}
}
.bounceInLeft {
-webkit-animation-name: bounceInLeft;
animation-name: bounceInLeft;
}
</style>
个字符
然后运行另一个,显示15秒,然后继续。
<style> #animated-example {
width: 300px;
height: 200px;
border: solid 1px #1A7404;
position: absolute;
background-color: #62A80A;
}
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes bounceInDown {
0% {
opacity: 0;
-webkit-transform: translateY(-2000px);
}
60% {
opacity: 1;
-webkit-transform: translateY(30px);
}
80% {
-webkit-transform: translateY(-10px);
}
100% {
-webkit-transform: translateY(0);
}
}
@keyframes bounceInDown {
0% {
opacity: 0;
transform: translateY(-2000px);
}
60% {
opacity: 1;
transform: translateY(30px);
}
80% {
transform: translateY(-10px);
}
100% {
transform: translateY(0);
}
}
.bounceInDown {
-webkit-animation-name: bounceInDown;
animation-name: bounceInDown;
}
</style>
<img id="animated-example" class="animated bounceInDown" src="https://www.facebookbrand.com/img/fb-art.jpg">
的字符串
4条答案
按热度按时间oymdgrw71#
使用
animation-delay
。字符串
动画
b
将在4秒后开始,而动画a
将在没有任何延迟的情况下开始。t40tm48m2#
在纯CSS中实现这一点的唯一方法是同时运行所有动画并进行一些计算:
当你在这里看到它的作用时,它会更清楚:
个字符
x9ybnkn63#
animation-delay
会做你正在寻找的事情 * 除了 * 你希望动画在最后一个完成后重复的事实;不幸的是,(目前)没有办法指定循环动画迭代之间的延迟。但是,您可以使用一点JavaScript来实现您想要做的事情,如下所示。要添加更多动画,只需将它们的类名添加到代码开头的
animations
数组中。jdgnovmf4#
我已经成功地实现了类似的东西,通过适应这个概念由诺亚艾迪:http://digitalfio.github.io/Stagger.css/
你需要在时间上做一些工作来获得你想要的15秒延迟,但除此之外,它应该是相当简单的。