gpt4 book ai didi

html - 强制 flexbox 列在 `flex-direction: column` 容器上相等

转载 作者:行者123 更新时间:2023-12-01 14:24:43 26 4
gpt4 key购买 nike

如何在 flex-direction: column 容器上强制 Flexbox 列的宽度相等(所有列的最大值)?我不想使用 flex-basiswidth 属性明确设置宽度。

JSFiddle:https://jsfiddle.net/suthanbala/1u9gtqkm/6/

.row{
display: flex;
flex-direction: column;
align-items: flex-start;
}

.column{
border: 1px red dashed;
}
<div class="row">
<div class="column">
Small Content
</div>
<div class="column">
Medium Content Medium Content
</div>
<div class="column">
Large Content Large Content Large Content
</div>
</div>

最佳答案

如果您希望所有列都与最大列一样宽,您可以制作容器 inline-flex 并删除对齐项:

.row{
display: inline-flex;
flex-direction: column;
}

.column{
border: 1px red dashed;
}
<div class="row">
<div class="column">
Small Content
</div>
<div class="column">
Medium Content Medium Content
</div>
<div class="column">
Large Content Large Content Large Content
</div>
</div>

关于html - 强制 flexbox 列在 `flex-direction: column` 容器上相等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59666966/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com