我正在尝试一次为 3 个 div 设置动画以淡入和淡出。我希望第一个淡入,暂停 2 秒然后淡出。然后第二个应该淡入,暂停 2 秒然后淡出,然后第三个 div 做同样的事情。现在动画不工作并且 div 根本没有淡入。下面是用于动画的 html 和 css。
<div class="fave-animate rag-and-bone-container">
<img class="rag-and-bone" src="/assets/images/rag-and-bone-boot.png"></img>
<div class="title">
<strong translate>Rag & Bone</strong>
<span translate>just for you.</span>
</div>
</div>
<div class="fave-animate asos-container">
<img class="asos" src="/assets/images/asos.png"></img>
<div class="title asos">
<strong translate>Asos</strong>
<span translate>just for you.</span>
</div>
</div>
<div class="fave-animate style-container">
<img class="style-inspiration" src="/assets/images/style-inspiration.png"></img>
<div class="title style">
<strong translate>Style inspiration</strong>
<span translate>just for you.</span>
</div>
</div>
.fave-content {
width: 100%;
height: 544px;
opacity: 0;
.fave-animate {
-webkit-animation-name: demo;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-iteration-count: infinite;
-webkit-animation-duration: 10s;
-webkit-animation-direction: alternate;
&.rag-and-bone-container {
-webkit-animation-delay: 0;
}
&.asos-container {
-webkit-animation-delay: 5s;
}
&.style-container {
-webkit-animation-delay: 10s;
}
}
@-webkit-keyframes demo {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
最佳答案
使用 & you 告诉 css reg 和 asos 是 fave 的子级,而当它们不是 fave 时,它们是 fave。
这是一个示例,其中包含三个 div 在此类动画中的行为,您应该能够从这里处理它。
http://jsfiddle.net/qdnsz1p8/1/
.fave-animate {
background:red;
padding:60px;
margin-right:10px;
width:40px;
float:left;
-webkit-animation: demo ease-in-out 5s infinite;
}
div.rag-and-bone-container {
-webkit-animation-delay: 0;
}
div.asos-container {
-webkit-animation-delay: 5s;
}
div.style-container {
-webkit-animation-delay: 10s;
}
@-webkit-keyframes demo {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
关于html - 按顺序淡入淡出 3 个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26494599/