我有一个有3个圆圈的CSS3圆形加载器。我有问题每个圆圈(从第一个开始)应该在几秒钟之后淡出可能使用CSS动画。任何帮助表示赞赏。
答案 0 :(得分:3)
我的路线略有不同。 仅适用于webkit,但您可以根据需要进行更改:http://jsfiddle.net/8kQ2u/17/
@-webkit-keyframes fades {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
.circle span {
display: inline-block;
width: 15px;
height: 15px;
margin: 9.975em auto;
background: #dbdbdb;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
-ms-border-radius: 50px;
-o-border-radius: 50px;
border-radius: 50px;
-webkit-animation-duration: 1.5s;
-webkit-animation-name: fades;
-webkit-animation-iteration-count: infinite;
}
.circle span:nth-child(2) {
-webkit-animation-delay: 0.2s;
}
.circle span:nth-child(3) {
-webkit-animation-delay: 0.4s;
}
:nth-child
这里很好,因为我非常确定它在支持@keyframes
的浏览器中得到了完全的支持。如果您愿意(+
),可以使用兄弟选择器。
答案 1 :(得分:1)
使用关键帧可以做到:http://jsfiddle.net/Nux3z/
一些细节:
1) Use of :nth-child, or :first-child, etc to target your elements
2) Timing of animations: I'm using 1.7, 2.7, rather than 0.7s, 1.4s because I'm allowing for the 1s of fade to finish NOT simply doubling/tripling the time each element takes to animate.
3) Not a solution for IE
答案 2 :(得分:0)
正如其他人所说,使用动画和计时在这里是基本的。
实际上,每个圆圈都使用相同的动画,
但您必须对每个圈子应用不同的延迟。
见下文(我也使用nth-child
代替first-child
):
.circle span {
/** The same animation to each circle **/
-webkit-animation: circleFade 3s linear infinite;
}
/** Different animation delays **/
.circle span:nth-child(1) { -webkit-animation-delay: 1s; }
.circle span:nth-child(2) { -webkit-animation-delay: 2s; }
.circle span:nth-child(3) { -webkit-animation-delay: 3s; }
/** Animation **/
@-webkit-keyframes circleFade {
0% { background: #ddd; }
25% { background: #999; }
35% { background: #999; }
60% { background: #ddd; }
}