使用.png图像,没有javascript / jquery的Css3淡入淡出过渡

时间:2015-11-02 09:58:59

标签: html html5 css3 css-transitions

我想要一个平滑的css3滑块,它有.png图像。一开始,所有图像显示一次,之后它工作正常。我需要帮助来隐藏转换开始时加载的三个图像。

如果有人可以提供帮助......会很高兴。

PS :我正在开发一些限制使用jquery / javascript的工具。因此,我的问题的许多解决方案都无法实现。



@-webkit-keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@-moz-keyframes cf4FadeInOut {
 0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@-o-keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

#cf4a {
  position:relative;
  height:571px;
  width:931px;
  margin:0 auto;
}
#cf4a img {
  position:absolute;
  left:0;
}
#cf4a img {
  -webkit-animation-name: cf4FadeInOut;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-iteration-count: infinite;
  -webkit-animation-duration: 24s;

  -moz-animation-name: cf4FadeInOut;
  -moz-animation-timing-function: ease-in-out;
  -moz-animation-iteration-count: infinite;
  -moz-animation-duration: 24s;

  -o-animation-name: cf4FadeInOut;
  -o-animation-timing-function: ease-in-out;
  -o-animation-iteration-count: infinite;
  -o-animation-duration: 24s;

  animation-name: cf4FadeInOut;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-duration: 24s;
}
#cf4a img:nth-of-type(4) {
	
  -webkit-animation-delay: 18s;
  -moz-animation-delay: 18s;
  -o-animation-delay: 18s;
  animation-delay: 18s;
}
#cf4a img:nth-of-type(3) {
  -webkit-animation-delay: 12s;
  -moz-animation-delay: 12s;
  -o-animation-delay: 12s;
  animation-delay: 12s;
  
}
#cf4a img:nth-of-type(2) {
  -webkit-animation-delay: 6s;
  -moz-animation-delay: 6s;
  -o-animation-delay: 6s;
  animation-delay: 6s;
  visibility: visible;
}
#cf4a img:nth-of-type(1) {
  -webkit-animation-delay: 0;
  -moz-animation-delay: 0;
  -o-animation-delay: 0;
  animation-delay: 0;
  
}

<div id="cf4a" class="shadow">
 <img src="header-img-1.png"  />
     <img src="header-img-2.png" />
    <img  src="header-img-3.png" />
        <img src="header-img-4.png"  />
        
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
@-webkit-keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@-moz-keyframes cf4FadeInOut {
 0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@-o-keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

@keyframes cf4FadeInOut {
0% {
    opacity:1;
  }
  15% {
    opacity:1;
  }
  25% {
    opacity:0;
  }
  90% {
    opacity:0;
  }
  100% {
    opacity:1;
  }
}

#cf4a {
  position:relative;
  height:571px;
  width:931px;
  margin:0 auto;
}
#cf4a img {
  position:absolute;
  left:0;
}


 #cf4a img {
-webkit-animation: cf4FadeInOut 24s ease-in-out infinite;
-moz-animation: cf4FadeInOut 24s ease-in-out infinite;
-o-animation: cf4FadeInOut 24s ease-in-out infinite;
 animation: cf4FadeInOut 24s ease-in-out infinite;
}
#cf4a img:nth-child(4) {
	
  -webkit-animation-delay: 18s;
  -moz-animation-delay: 18s;
  -o-animation-delay: 18s;
  animation-delay: 18s;
}
#cf4a img:nth-child(3) {
  -webkit-animation-delay: 12s;
  -moz-animation-delay: 12s;
  -o-animation-delay: 12s;
  animation-delay: 12s;
  
}
#cf4a img:nth-child(2) {
  -webkit-animation-delay: 6s;
  -moz-animation-delay: 6s;
  -o-animation-delay: 6s;
  animation-delay: 6s;
  visibility: visible;
}
#cf4a img:nth-child(1) {
  -webkit-animation-delay: 0;
  -moz-animation-delay: 0;
  -o-animation-delay: 0;
  animation-delay: 0;
  
}
&#13;
<div id="cf4a" class="shadow">
 <img src="header-img-1.png"  />
     <img src="header-img-2.png" />
    <img  src="header-img-3.png" />
        <img src="header-img-4.png"  />
        
</div>
&#13;
&#13;
&#13;

我希望这能解决你的问题,你的这个工作小提琴https://jsfiddle.net/3t8qysk6/