当child元素最后一行不为3个时,这样写会导致最后一行的元素垂直方向上不与之前的行元素对齐
parent {
width: 300px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
child {
width: 100px;
height: 50px;
}
只需要在parent加一个CSS伪类即可解决
parent {
width: 300px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
&::after {
content: '';
flex: auto;
}
}