我正在尝试让我的内容像这样显示picture
但是我的picture是这样的
如何使一行有3列,第二行有4列,最后一行有3列?使用flexbox?谢谢
.flex-container {
display: flex;
flex-flow: row wrap;
justify-content: center;
background-color: white;
align-items:baseline;
width: 60em;
margin: auto;
padding: .5em;
justify-content: space-between;
}
.flex-container div {
flex: 1 0 30%;
margin: .5em 0;
text-align: center;
line-height: 1.5em;
font-size: 1em;
border: 0.1em solid black;
padding: 5px;
box-sizing: border-box;
justify-content: space-between;
}发布于 2021-01-27 14:13:38
您可以通过将单元格放置到行中来实现这一点,这些行本身使用flex-direction: column进行堆叠。
样式很粗糙,但请尝试如下所示:
.outer {
display: flex;
flex-direction: column;
}
.row {
display: flex;
flex-direction: row;
}
.cell {
margin: 1.0em;
padding: 1.0em;
border: 1px solid black;
flex-grow: 1;
}<div class="outer">
<div class="row">
<div class="cell">Cell 1</div>
<div class="cell">Cell 2</div>
<div class="cell">Cell 3</div>
</div>
<div class="row">
<div class="cell">Cell 3</div>
<div class="cell">Cell 4</div>
<div class="cell">Cell 5</div>
<div class="cell">Cell 6</div>
</div>
<div class="row">
<div class="cell">Cell 7</div>
<div class="cell">Cell 8</div>
<div class="cell">Cell 9</div>
</div>
</div>
https://stackoverflow.com/questions/65913597
复制相似问题