【发布时间】:2022-01-22 09:57:55
【问题描述】:
我正在学习 flexbox,我想制作一个如下所示的布局:
于是我做了如下代码:
.container {
display: flex;
gap: 26px;
}
.flex50 {
flex: 50%;
flex-wrap: wrap;
min-width: calc(50% - 13px);
background-color: #000000;
margin-bottom: 26px;
}
.flex33 {
flex: 33.33333%;
flex-wrap: wrap;
min-width: 33.33333%;
background-color: #000000;
margin-bottom: 26px;
}
<div class="container">
<div class="flex50">
1 50
</div>
<div class="flex50">
2 50
</div>
<div class="flex33">
1 33
</div>
<div class="flex33">
2 33
</div>
<div class="flex33">
3 33
</div>
<div class="flex33">
4 33
</div>
</div>
但正如您所看到的,这条线并没有像它应该的那样断线。我哪里错了?
【问题讨论】:
-
flex-wrap: wrap位于父容器上,而不是flex50或flex33元素 -
我投票决定关闭它,因为从技术上讲,这是一个错误元素上的 flex-wrap 属性的错字。