【发布时间】:2016-01-05 13:48:03
【问题描述】:
我创建了一个幻灯片,其中包含来自其他非常有才华的人的大量输入(我正在学习)。但是,我的代码似乎一直到第五张图片,但很快又回到了第一张,而不是与前四张幻灯片保持相同的时间表。我试图避免使用 JS 或 jQuery。我觉得它更容易阅读,尤其是考虑到我的 Java 背景很少。
这是我目前使用的代码:
@import url(http://fonts.googleapis.com/css?family=Istok+Web);
@keyframes slidy {
0% {
left: 0%;
}
20% {
left: 0%;
}
25% {
left: -100%;
}
45% {
left: -100%;
}
50% {
left: -200%;
}
70% {
left: -200%;
}
75% {
left: -300%;
}
95% {
left: -300%;
}
100% {
left: -400%;
}
}
body,
figure {
margin: 0;
background: #101010;
font-family: Istok Web, sans-serif;
font-weight: 100;
}
div#captioned-gallery {
width: 100%;
overflow: hidden;
}
figure.slider {
position: relative;
width: 500%;
font-size: 0;
animation: 60s slidy infinite;
}
figure.slider figure {
width: 20%;
height: auto;
display: inline-block;
position: inherit;
}
figure.slider img {
width: 100%;
height: 95%;
}
figure.slider figure figcaption {
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
color: #fff;
width: 100%;
font-size: 2rem;
padding: .6rem;
}
<div id="captioned-gallery">
<figure class="slider">
<figure>
<img src="http://lorempixel.com/800/600/nature/1">
</figure>
<figure>
<img src="http://lorempixel.com/800/600/nature/2">
</figure>
<figure>
<img src="http://lorempixel.com/800/600/nature/3">
</figure>
<figure>
<img src="http://lorempixel.com/800/600/nature/4">
</figure>
<figure>
<img src="http://lorempixel.com/800/600/nature/5">
</figure>
<figure>
<img src="http://lorempixel.com/800/600/nature/6">
</figure>
</figure>
</div>
所以我认为关键帧部分一定有问题。但是,我认为我可能只是在这方面很糟糕,并且很难找到对我有意义的好参考。我弄乱了百分比,但似乎无法正确处理。我主要需要知道关键帧是如何工作的,以及工作是如何在每张幻灯片中分配的。我什至想知道如何在组合中添加另一张幻灯片,但解决第一个问题将是一个很好的开始。我很感激你花时间来剖析这个。非常感谢所有帮助。
【问题讨论】:
标签: html css slideshow css-animations