使用 CSS3 的 column 属性
<view class="pop-waterfall">
<view class="pop-watitem" v-for="(item, index) in popwaterList" :key="index">
<!-- 内容 -->
<view class="pop-water-listonce">
<!-- <image src="https://pic.qqans.com/up/2024-5/17153079846560011.jpg" mode="">
</image> -->
<view class="cate">
<image :src="item.img[0]" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<script>
export default{
data(){
return{
popwaterList: [ //瀑布流列表
{
img: ['https://pic1.zhimg.com/80/v2-1453c09d39a9b29e0b4e7f3f1172632e_720w.webp'],
name: '有哪些好看的女主爽文?',
userimg: 'https://pic4.zhimg.com/80/v2-387a660c3792c0ddb01b3c04411b90a3_720w.webp',
username: '小樱'
},
{
img: ['https://pic4.zhimg.com/80/v2-730ff54e9744af3e38839e4116b85d25_720w.webp'],
name: '对于熊猫的了解你有多少呢?',
userimg: 'https://pic1.zhimg.com/80/v2-6a71bee4d49faea425a85060395ea072_720w.webp',
username: '旭旭看熊猫'
},
{
img: ['https://pic4.zhimg.com/80/v2-730ff54e9744af3e38839e4116b85d25_720w.webp'],
name: '怎样看待汤兰兰事件?',
userimg: 'https://pica.zhimg.com/80/v2-e8646e601234b5e141a81caf09e8983c_720w.webp',
username: '百川帕萨'
},
{
img: ['https://pic1.zhimg.com/80/v2-1453c09d39a9b29e0b4e7f3f1172632e_720w.webp'],
name: '《还珠格格》里面,皇帝是更喜欢小燕子还是更喜欢紫薇一些?',
userimg: 'https://pica.zhimg.com/80/v2-1b7febbabafae623ad3e48aec0fd0dd4_720w.webp',
username: '千与千寻'
},
{
img: ['https://pic4.zhimg.com/80/v2-941745e571b37cacecc05296c0cd920f_720w.webp'],
name: '吃素久了能闻出吃肉的人身上有臭味,是真的吗?',
userimg: 'https://pic4.zhimg.com/80/v2-6107447d578a24df6cbc79aa9085bfad_720w.webp',
username: '无脸怪'
},
{
img: ['https://pic3.zhimg.com/v2-39ff5708df7e583a1b21c277ab3cd39e_b.jpg'],
name: '床上总是有螨虫,有什么解决方案?',
userimg: 'https://pic4.zhimg.com/80/v2-387a660c3792c0ddb01b3c04411b90a3_720w.webp',
username: '生活百变机'
},
{
img: ['https://pic1.zhimg.com/v2-2dbe09217e5c9a21149abb04e99ea510_b.jpg'],
name: '为什么美国的肯德基可乐饮料可以免费续杯?',
userimg: 'https://picx.zhimg.com/80/v2-1c1a376f3e9eeab5335497042f7953b7_720w.webp',
username: '千山补给你'
},
{
img: ['https://pic3.zhimg.com/v2-39ff5708df7e583a1b21c277ab3cd39e_b.jpg'],
name: '生活中的哪个瞬间,让你意识到「这是独属于中国人自古以来骨子里的浪漫」?',
userimg: 'https://pica.zhimg.com/80/v2-ddd9379815c5d8a8f10f5e2b90e4fb8e_720w.webp',
username: 'subsijnfg'
},
{
img: ['https://pic4.zhimg.com/v2-8e29e5338ae30b7ad58f29da805db39f_b.jpg'],
name: '什么事情让你意识到,好言难劝该死的鬼?',
userimg: 'https://pic1.zhimg.com/80/v2-c05cf5c8afbd8ea0c114762c82400bb8_720w.webp',
username: '阿贝贝'
}
]
}
}
}
</script>
<style lang="scss">
.pop-waterfall {
column-count: 2;
/* 列数,可以根据屏幕宽度动态设置 */
column-gap: 10px;
/* 列与列之间的间隔 */
.pop-watitem {
break-inside: avoid; /* 避免在元素内部进行分页 */
margin-bottom: 10px; /* 每个元素的下边距 */
.pop-water-listonce{
width: 45vw;
image{
width: 45vw;
}
}
}
}
</style>
![](https://i-blog.csdnimg.cn/direct/d0abb3ea1da84d5ea00c8e52885c50bb.png)