【发布时间】:2016-11-09 14:21:05
【问题描述】:
我正在尝试通过在 HTML 中再添加一张图片来自定义给定 here 的滑块。
当我在 HTML 中添加图像并在 CSS 中进行相应更改时,代码会中断并且无法正常工作。
这是滑块的 HTML 代码:
/*Here is the CSS code: */
@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 {
margin: 0;
}
div#slider {
overflow: hidden;
}
div#slider figure img {
width: 20%;
float: left;
}
div#slider figure {
position: relative;
width: 500%;
margin: 0;
left: 0;
text-align: left;
font-size: 0;
animation: 30s slidy infinite;
}
<base href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/">
<div id="slider">
<figure>
<img src="austin-fireworks.jpg" alt>
<img src="taj-mahal_copy.jpg" alt>
<img src="ibiza.jpg" alt>
<img src="ankor-wat.jpg" alt>
<img src="austin-fireworks.jpg" alt>
</figure>
</div>
我尝试在<figure> 中添加图像,但滑块停止工作。
您可以在Codepen.io website 运行代码。
【问题讨论】:
标签: css html slider css-animations