【发布时间】:2018-02-15 23:59:37
【问题描述】:
这是一个代码,我对其进行了一些修改,以仅使用 HTML 和 CSS 制作带有图像的简单幻灯片:
(这是部分代码查看全部请点击demo)
代码:
.slideshow {
width: 800px;
margin: 0 auto;
overflow: hidden;
border: solid 1px white;
}
.slideshow-container {
width: 2500px;
font-size: 0;
transition: 1s ease;
height: 225px;
}
@keyframes slide {
0% {
transform: translateX(0%);
}
12.5% {
transform: translateX(0%);
}
25% {
transform: translateX(-25%);
}
37.5% {
transform: translateX(-25%);
}
50% {
transform: translateX(-50%);
}
62.5% {
transform: translateX(-50%);
}
75% {
transform: translateX(-75%);
}
87.5% {
transform: translateX(-75%);
}
99% {
transform: translateX(-75%);
}
100% {
transform: translateX(0);
}
}
<section class="slideshow">
<div class="slideshow-container slide">
<img src="http://placeimg.com/625/225/any" />
<img src="http://placeimg.com/625/225/animals" />
<img src="http://placeimg.com/625/225/arch" />
</div>
</section>
我想在每个图像旁边添加一个文本,所以在框架中我将有一半图像和另一半文本。 我怎样才能做到这一点?
【问题讨论】:
-
看看这个兄弟 --> stackoverflow.com/questions/48204183/…
-
hm,尝试制作容器div,包括图像和文本,设置样式。例如 20% 的文本宽度,另外 80% 的图像宽度。
-
如果我将每个 img 放在一个 div 中,则只有第一张图片不会显示其他图片
标签: html css flexbox css-transitions