最佳答案
可能您正在寻找数量查询,您可以根据列表中的项目数来更改样式
.container {
display: flex;
flex-flow: row wrap;
border: solid 1px green;
}
.container > div {
flex: 1 0;
background-color: lightgreen;
height: 30px;
margin: 5px;
}
.item:first-child:nth-last-child(3),.item:first-child:nth-last-child(3) ~ .item {
flex-basis: 30%;
}
.item:first-child:nth-last-child(4),.item:first-child:nth-last-child(4) ~ .item {
flex-basis: 40%;
}