html css交叉淡入计时器

html css交叉淡入计时器,html,cross-fade,Html,Cross Fade,我有一个简单的网页,我想做的是在第一张图片中淡入5秒钟,然后将其更改为picture#2 5秒钟。这是我的密码: <!DOCTYPE html> <html> <style> #cf { position:relative; height:281px; width:450px; margin:0 auto; } #cf img { position:absolute; left:0; -webkit-transition: opa

我有一个简单的网页,我想做的是在第一张图片中淡入5秒钟,然后将其更改为picture#2 5秒钟。这是我的密码:

<!DOCTYPE html>
<html>
<style>
#cf {
  position:relative;
  height:281px;
  width:450px;
  margin:0 auto;
}

#cf img {
  position:absolute;
  left:0;
  -webkit-transition: opacity 1s ease-in-out;
  -moz-transition: opacity 1s ease-in-out;
  -o-transition: opacity 1s ease-in-out;
  transition: opacity 1s ease-in-out;
}

  @keyframes cf3FadeInOut {
  0% {
  opacity:1;
}
45% {
opacity:1;
}
55% {
opacity:0;
}
100% {
opacity:0;
}
}

#cf img.top {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: 30s;
animation-duration: 10s;
animation-direction: alternate;
}
}
</style>
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="fade.css">
    <title>Wideout</title>
</head>
<body>

<iframe width="560" height="315" 
src="https://www.youtube.com/embed/seMwpP0yeu4" 
frameborder="0" allowfullscreen></iframe>

<div id="cf">
  <img class="bottom" src="images/1.jpg" height="100" />
  <img class="top" src="images/2.jpg" height="100" />
</div>

</body>
</html>

#碳纤维{
位置:相对位置;
高度:281px;
宽度:450px;
保证金:0自动;
}
#cf img{
位置:绝对位置;
左:0;
-webkit转换:不透明度1s易入易出;
-moz过渡:不透明度1s缓进缓出;
-o型过渡:不透明度1s缓进缓出;
过渡:不透明度1s缓进缓出;
}
@关键帧cf3FadeInOut{
0% {
不透明度:1;
}
45% {
不透明度:1;
}
55% {
不透明度:0;
}
100% {
不透明度:0;
}
}
#cf img.top{
动画名称:cf3FadeInOut;
动画计时功能:轻松进出;
动画迭代次数:30秒;
动画持续时间:10秒;
动画方向:交替;
}
}
广泛的

我相信我的问题在于百分比部分。有人能帮我吗?非常感谢

仅使用CSS3即可完成此操作

#crossfade > img { 
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
-webkit-animation: imageAnimation 30s linear infinite 0s;
-moz-animation: imageAnimation 30s linear infinite 0s;
-o-animation: imageAnimation 30s linear infinite 0s;
-ms-animation: imageAnimation 30s linear infinite 0s;
animation: imageAnimation 30s linear infinite 0s; 
}

#crossfade > img:nth-child(2)  {
-webkit-animation-delay: 6s;
-moz-animation-delay: 6s;
-o-animation-delay: 6s;
-ms-animation-delay: 6s;
animation-delay: 6s; 
}

@-webkit-keyframes imageAnimation { 
0% { opacity: 0;
-webkit-animation-timing-function: ease-in; }
8% { opacity: 1;
     -webkit-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
} 

@-moz-keyframes imageAnimation { 
0% { opacity: 0;
-moz-animation-timing-function: ease-in; }
8% { opacity: 1;
     -moz-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}

@-o-keyframes imageAnimation { 
0% { opacity: 0;
-o-animation-timing-function: ease-in; }
8% { opacity: 1;
     -o-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}

@-ms-keyframes imageAnimation { 
0% { opacity: 0;
-ms-animation-timing-function: ease-in; }
8% { opacity: 1;
     -ms-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}

@keyframes imageAnimation { 
0% { opacity: 0;
animation-timing-function: ease-in; }
8% { opacity: 1;
     animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }

}
检查

这是