【发布时间】:2016-01-13 06:19:54
【问题描述】:
我正在尝试制作多行具有相同高度的正方形(每行 3 个)。
我为此编写了一些 HTML 和 CSS,但这些框都在同一行。
这是我目前所拥有的:
#list-wrapper {
display: flex;
width: 100%;
}
#list-wrapper div {
width: 33.33%;
}
#list-wrapper div img {
flex: 1;
}
<div id="list-wrapper">
<div>
<img src="images/1.png" alt="image one" />
</div>
<div>
<img src="images/2.png" alt="image two" />
</div>
<div>
<img src="images/1.png" alt="image one" />
</div>
<div>
<img src="images/2.png" alt="image two" />
</div>
<div>
<img src="images/1.png" alt="image one" />
</div>
<div>
<img src="images/2.png" alt="image two" />
</div>
</div>
当我用这个加载页面时,所有的框都会出现,但它们都在一条线上,超过了父 div 的 100% 宽度。
【问题讨论】: