【发布时间】:2020-06-17 03:23:32
【问题描述】:
感谢我在此处 (How do I determine the height of a row?) 对我的问题的回答,我现在明白(查看下面的示例),通过在第一个 flex 行中的 flex-item 上设置 60px 的显式高度,它可以降低高度align-content: stretch 必须从 200 像素(容器的高度)到 140 像素“播放”。由于有 2 条 flex-line,它被分成两半,第一个 flex-line 为 70px,第二个 flex-line 为 70px。现在第一个 flex-line 的高度是该行上最高的 flex-item 的高度(60px)加上 70px 得到 130px。第二条flex-line的高度是70px。
实际上,每个 flex-line 的高度略有不同(第一个 flex-line 大约 122px,第二个 78px)我被告知这与文本内容的高度有关。
有人能详细说明吗?
.flex-container {
display: flex;
flex-wrap: wrap;
width: 400px;
height: 200px;
border: 1px solid black;
}
.flex-container> :nth-child(1) {
background-color: darkorchid;
height: 60px;
}
.flex-container> :nth-child(2) {
background-color: darkkhaki;
}
.flex-container> :nth-child(3) {
background-color: dodgerblue;
}
.flex-container> :nth-child(4) {
background-color: darkgoldenrod;
}
.flex-container> :nth-child(5) {
background-color: darkcyan;
}
<div class="flex-container">
<span>I am number 1</span>
<div>I am number 2</div>
<div>I am number 3</div>
<div>I am number 4</div>
<span>I am number 5</span>
</div>
【问题讨论】: