这是我需要的效果:也就是父盒子未设置高度,随着子盒子一起被动下移,脱离文档流
方法就是直接给父元素加一个:overflow:hidden
<template>
<div class="father">
<div class="one-line">
<div class="one-line-box" v-for="i in 12">
{{ i }}
</div>
</div>
</div>
</template>
.father {
width: 100%;
height: 100%;
background-color: #e4e9ed;
overflow: hidden;
}
.one-line {
width: 98%;
height: 160px;
margin: auto;
margin-top: 10px;
background-color: white;
display: flex;
flex-wrap: wrap;
}
.one-line-box {
width: 200px;
height: 50px;
border: 1px solid #e4e9ed;
margin: 10px;
}