【发布时间】:2021-04-18 16:46:31
【问题描述】:
我有一个div,它包含 3 个 div,在 flex-direction 列中。
有什么办法,我可以让底部的两个红色div,并排坐在一起(并排)。而且不是在彼此之上?像这样:
我知道我可以将这两个红色 div 存储在另一行并将方向设置为行。
但我想知道这是否可以实现,特别是使用这种 html 结构:
谢谢,
.main {
display: flex;
flex-direction: column;
width: 200px;
border: 1px solid black;
}
.top {
background-color: blue;
color: red;
width: 100%;
height: 50px;
}
.bottom {
background-color: red;
color: white;
width: 50%;
height: 50px;
}
<div class="main">
<div class="box top">Box 1</div>
<div class="box bottom">Box 2</div>
<div class="box bottom">Box 3</div>
</div>
<div class="main">
<div class="box top">Box 1</div>
<div class="box bottom">Box 2</div>
<div class="box bottom">Box 3</div>
</div>
【问题讨论】: