图片CSS过渡问题

时间:2013-06-02 06:19:49

标签: html5 css3 animation transition slide

我有一张在四张照片之间转换的幻灯片。我的幻灯片以一定的速度运行,但最后一张幻灯片没有快速转换回第一张幻灯片。我试图添加另一个nth,我试图减慢最后一个,但它不起作用。我希望整个幻灯片在某个时间过渡,但最后一张幻灯片需要回到第一张幻灯片而没有我得到的巨大的黑色延迟。这是代码:

    .picTransition .item {
  position: absolute;
  left: 0;
  right: 0;
  opacity: 0;
  -webkit-animation: picTransition 56s linear infinite;
  -moz-animation: picTransition 56s linear infinite;
  -ms-animation: picTransition 56s linear infinite;
  animation: picTransition 56s linear infinite;
}
.picTransition .item:nth-child(2) {
  -webkit-animation-delay: 12s;
  -moz-animation-delay: 12s;
  -ms-animation-delay: 12s;
  animation-delay: 12s;
}
.picTransition .item:nth-child(3) {
  -webkit-animation-delay: 24s;
  -moz-animation-delay: 24s;
  -ms-animation-delay: 24s;
  animation-delay: 24s;
}
.picTransition .item:nth-child(4) {
  -webkit-animation-delay: 36s;
  -moz-animation-delay: 36s;
  -ms-animation-delay: 36s;
  animation-delay: 36s;
}

@-webkit-keyframes picTransition {
    0%, 25%, 100% { opacity: 0; }
    4.17%, 20.84% { opacity: 1;}
}
@-moz-keyframes picTransition {
    0%, 25%, 100% { opacity: 0; }
    4.17%, 20.84% { opacity: 1;}
}
@-ms-keyframes picTransition {
    0%, 25%, 100% { opacity: 0; }
    4.17%, 20.84% { opacity: 1;}
}
@keyframes picTransition {
    0%, 25%, 100% { opacity: 0; }
    4.17%, 20.84% { opacity: 1;}
}

我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

如果您有4张图片并且已设置

animation-delay: 12s;

对于每一个,cicle时间是4 * 12 = 48s。

相反,您的周期时间为56秒

animation: picTransition 56s linear infinite;

这意味着结尾有8秒的间隙