首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >依次淡入淡出3个div

依次淡入淡出3个div
EN

Stack Overflow用户
提问于 2014-10-22 03:21:16
回答 2查看 294关注 0票数 0

我正在尝试动画3个div一次一个淡入和淡出。我希望第一个淡入,停顿2秒,然后淡出。然后第二个div应该淡入,暂停2秒,然后淡出,第三个div也是这样做的。现在动画不起作用,div一点也不淡出。下面是用于动画的html和css。

代码语言:javascript
复制
<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;
    }
  }
EN

回答 2

Stack Overflow用户

发布于 2014-10-22 03:40:29

您的动画序列与要求不匹配。

这应该会在10秒内发生

代码语言:javascript
复制
 @-webkit-keyframes demo {
    0% {
      opacity: 0;
    }

    50% {
      opacity: 1;
    }

    100% {
      opacity: 0;
    }
  }

没有暂停here..once,序列达到50%,它立即开始恢复到0不透明度。所以实际的序列应该看起来像...

代码语言:javascript
复制
 @-webkit-keyframes demo {
    0% {
      opacity: 0; /* take 4 seconds */
    }

    40% {
      opacity: 1; /* pauses for 2 seconds (20% of 10 seconds) */
    }

    60% {
      opacity: 1; /* still at full opacity but now resumes taking another 4 second */
    }

    100% {
      opacity: 0;
    }
  }

您还可以删除计时功能。

票数 0
EN

Stack Overflow用户

发布于 2014-10-22 03:45:03

使用& you where告诉css,reg和aso是fave的子级,而它们不是,它们是fave。

这是一个在这样的动画中表现的三个div的示例,你应该能够在这里处理它。

http://jsfiddle.net/qdnsz1p8/1/

代码语言:javascript
复制
.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;
  }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26494599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档