flex布局--一行显示固定个数
2024年1月25日小于 1 分钟约 214 字
<div class="programImgInfo">
<span v-for="(item, index) in imgGroup"
:key="item.name"
:style="item.imgStyle">
<img v-if="item.imgPath" :src="item.imgPath">
</span>
</div><!-- more -->
setup() {
let imgGroup = reactive([
{name: "resolution", imgStyle: {width: "124px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "sound", imgStyle: {width: "84px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "subtitle", imgStyle: {width: "50px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "signal", imgStyle: {width: "84px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "dCopy", imgStyle: {width: "130px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "optCopy", imgStyle: {width: "130px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "ageLimit", imgStyle: {width: "78px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null},
{name: "ppv", imgStyle: {width: "138px", height: "32px", background: "rgb(23, 23, 24)"}, imgPath: null}
])
return {
imgGroup
}
}.programImgInfo {
display: flex;
flex-wrap: wrap;
align-items: center;
margin-left: 70px;
grid-gap: 10px;
>span {
width: calc((100% - 60px) / 5)
}
&:nth-child(4n + 4) {//从某行开始margin-right: 0;
margin-right: 0;
}
}