这种布局通过flex似乎无法实现,所以这里通过grid来实现
.test_div {
width: 320px;
height: 300px;
border: 1px solid red;
display: grid;
grid-gap: 10px 5px;
grid-template-columns: repeat(6, 50px);
grid-template-rows: repeat(2, 100px);
div {
width: 100px;
height: 100px;
border: 1px solid blue;
grid-column: span 2;
grid-row: span 1;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
&:nth-of-type(1) {
grid-column-start: 2;
grid-column-end: 4;
}
}
}
.test_div1 {
width: 320px;
height: 300px;
border: 1px solid red;
display: grid;
grid-gap: 10px 5px;
grid-template-columns: repeat(4, 50px);
grid-template-rows: repeat(2, 100px);
div {
width: 100px;
height: 100px;
border: 1px solid blue;
grid-column: span 2;
grid-row: span 1;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
&:nth-of-type(1) {
grid-column-start: 2;
grid-column-end: 4;
}
}
}