【发布时间】:2021-10-15 10:56:25
【问题描述】:
自从我不得不使用 HTML 或 CSS 以来已经有一段时间了。我正在尝试在水平线上添加 3-4 个图像以及每个图像下方的一些文本。我希望每个图像+文本均匀分布,并且在调整浏览器大小时也让它们垂直堆叠。解决此问题的最佳方法是什么?我现在的代码绝对是垃圾,老实说,我不知道从哪里开始。
<style><!--
#container {
height: 125px;
text-align: justify;
-ms-text-justify: distribute-all-lines;
text-justify: distribute-all-lines;
}
.box1,
.box2,
.box3,
.box4 {
width: 150%;
height: 125%;
vertical-align: top;
display: inline-block;
*display: inline;
zoom: 1
}
.stretch {
width: 100%;
display: inline-block;
font-size: 0;
line-height: 0
}
--></style>
<div id="container">
<div class="box1"><img src="img" /><b text-align="center">Test for bold header</b><br />
<p>This is a bunch of test text to see if the text will actually center below the image</p>
</div>
<div class="box2"><img src="img" width="200px" />
<p>This is a bunch of test text to see if the text will actually center below the image</p>
</div>
<div class="box3"><img src="img" width="200px" />
<p>This is a bunch of test text to see if the text will actually center below the image</p>
</div>
<div class="box4"><img src="img" width="200px" />
<p>This is a bunch of test text to see if the text will actually center below the image</p>
</div>
<span class="stretch"></span></div>
我确信有一种更简单的方法可以做到这一点,它不需要我拼凑的所有这些废话。我试图在“为什么有效”部分下模仿类似 https://tomorrowslaundry.co/pages/essentials-club-welcome?sscid=81k5_bf9d1& 的内容
任何帮助或指导将不胜感激。
【问题讨论】:
标签: html css image responsive-design responsive