作者:sannyi | 来源:互联网 | 2023-02-11 09:25
我正在尝试使用flexbox重新创建以下布局:
我几乎有布局明智,但我得到一些奇怪的flex-wrap行为,如下所示:
我的css如下:
.parent {
display: flex;
justify-content: space-between;
.square-container {
width: calc(33% - 1.333px);
display: flex;
flex-wrap: wrap;
justify-content: space-between;
&:before {
content:'';
float:left;
padding-top:100%;
}
.small-square {
width: calc(50% - 2px);
height: calc(50% - 2px);
background: red;
flex-shrink: 0;
}
}
}
html如下:
我觉得我在这里错过了一些重要的flexbox属性.谢谢您的帮助!
1> Pete..:
你可以很容易地做到:
.flex {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 210px;
justify-content: space-between;
width: 650px;
}
.small {
width: 100px;
height: 100px;
background: red;
}
.large {
width: 210px;
height: 210px;
background: red;
}