我试图让 flexbox 中的一个特殊 `
` 元素高度扩展到两行的高度。这是我的目标:期望效果。但这是我当前的结果:实际效果。
我认为我必须使用
我认为我必须使用
flex-wrap: wrap;
,但我不确定。我不想使用 flex-direction: column;
,因为那样我不能像在一行中对齐一样拉伸顶部的 `` 元素。我希望所有的子 `
` 元素都属于同一个 flex 容器。有没有人有什么想法?
注意:我发现了 这个,我能够创建出这个。如果我能把 "Three" 移动到 "Two" 旁边,我可能就能达到我想要的效果。但我不知道怎么做。
这是我正在使用的代码:
谢谢。
注意:我发现了 这个,我能够创建出这个。如果我能把 "Three" 移动到 "Two" 旁边,我可能就能达到我想要的效果。但我不知道怎么做。
这是我正在使用的代码:
.flex-row {
display: flex;
flex: 1;
flex-direction: row;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-col {
margin: 5px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
display: flex;
justify-content: center;
align-items: center;
flex: 1;
flex-direction: column;
padding: 10px;
box-sizing: border-box;
}
<div class="flex-row">
<div class="flex-col">
<p>This box has little text.</p>
</div>
<div class="flex-col">
<p>This box is diffrent than small. It has a middleish amout of text.</p>
</div>
<div class="flex-col">
<p>This box is diffrent than small and middleish. It has a lot of text. Thus, I want it to continue onto the next row of flexboxes.</p>
</div>
<div class="flex-col">
<p>This box has little text.</p>
</div>
<div class="flex-col">
<p>This box is diffrent than small. It has a middleish amout of text.</p>
</div>
</div>
.flex-col
都必须是.flex-row
的直接子元素吗? - Rainbow.flex-col
都在同一个flex容器中。 - BGM52