【发布时间】:2018-06-26 13:27:07
【问题描述】:
有没有办法让具有flex-direction: column 的弹性容器中的弹性项目具有相同的高度,仅使用 CSS?
<div style="display: flex; flex-direction: column;">
<div class="flex-item">
<!-- other html elements with image, links, button etc. -->
</div>
<!-- ... -->
<div class="flex-item"></div>
</div>
JSFiddle:https://jsfiddle.net/hzxa9v54/
【问题讨论】:
-
是的。只需使用
height。这就是它的用途。 -
我相信给每个孩子
flex: 1;会在使用flex-direction: column;时保持所有身高相等 -
@TricksfortheWeb 高度值不起作用,因为弹性项目具有不同的内容
-
@mcmxc 你需要一个脚本来做到这一点。
-
@Michael_B 由于即使在图像加载后网格似乎也会调整,我建议您将其发布为无脚本答案:)