您需要为animation-delay所有元素添加不同的内容。
使用animation-direction: alternate---> jsbin的演示
@keyframes load {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.e {
width: 100%;
height: 30px;
opacity: 0;
}
.one {
background: red;
-webkit-animation: load 5s infinite;
animation: load 5s infinite;
}
.two {
background: green;
-webkit-animation: load 5s infinite 1s;
animation: load 5s infinite 1s;
}
.three {
background: yellow;
-webkit-animation: load 5s infinite 2s;
animation: load 5s infinite 2s;
}
.four {
background: pink;
-webkit-animation: load 5s infinite 3s;
animation: load 5s infinite 3s;
}
.five {
background: purple;
-webkit-animation: load 5s infinite 4s;
animation: load 5s infinite 4s;
}Run Code Online (Sandbox Code Playgroud)
<div class="e one"></div>
<div class="e two"></div>
<div class="e three"></div>
<div class="e four"></div>
<div class="e five"></div>Run Code Online (Sandbox Code Playgroud)
我知道这是旧票,但我希望我的回答可以帮助别人。
如果你可以使用 css 插件,那么使用这个: https: //daneden.github.io/animate.css/
保留方便的自定义 CSS 以进行延迟并相应地使用,如下所示:
.anim-delay-500ms { animation-delay: 0.5s }
.anim-delay-1000ms { animation-delay: 1s }
.anim-delay-1500ms { animation-delay: 1.5s }
.anim-delay-2000ms { animation-delay: 2s }
Run Code Online (Sandbox Code Playgroud)
HTML 应该看起来像这样:
<div class="animated fadeInDown anim-delay-500ms">First Content</div>
<div class="animated fadeInDown anim-delay-1500ms">Second Content</div>
<div class="animated fadeInDown anim-delay-2000ms">Third Content</div>
<div class="animated fadeInDown anim-delay-2500ms">Fourth Content</div>
Run Code Online (Sandbox Code Playgroud)
这里有一些与animation.css一起使用的附加控件
#yourElement {
-vendor-animation-duration: 3s;
-vendor-animation-delay: 2s;
-vendor-animation-iteration-count: infinite;
}
Run Code Online (Sandbox Code Playgroud)
注意:请务必将 CSS 中的“供应商”替换为适用的供应商前缀(webkit、moz 等)
有关更多文档,您可以参考此处: https://github.com/daneden/animate.css/