uniapp使用css实现瀑布流

页面

复制代码
<template>
    <view>
        <gj v-if="likeList.length == 0"></gj>
        <view v-else class="list">
        <view class="pbl" v-for="(item,index) in likeList" :key="index">
            <view class="image">
                <image  fade-show  lazy-load :lazy-load-margin="0" mode="widthFix" :src="item.img"></image>
            </view>
            <view class="title">
                {{item.title}}
            </view>
            <view class="more">
                <view class="autohr">
                    {{item.author}}
                </view>
                <view class="like">
                    {{item.like}}
                </view>
            </view>
        </view>
        </view>
    </view>
</template>

<script>
    import gj from '../gj.vue'
    export default {
        components:{gj},
        data() {
            return {
                title: 'Hello',
                likeList:[
                ]
            }
        },
        onLoad() {
            this.getData()
        },
        methods: {
            getData(){
                setTimeout(()=>{
                    this.likeList=[{
                    title:"这样的礼物你喜欢吗?",
                    img:"https://sns-webpic-qc.xhscdn.com/202406120934/e794f1ff25b0b3492af7becb4c427e91/1040g2sg3134kh5lh6c705o7vonl08qarfhj9s30!nc_n_webp_mw_1",
                    author:"椰子哦",
                    like:"314"
                    },{
                    author:"快乐样",
                    like:"325",
                    title:"大佬点的黑桃全家桶,今晚不醉不归,大干下一场,大家一起来!!!",
                    img:"https://sns-webpic-qc.xhscdn.com/202406120934/074bf5b39465a1a7342f7ba55c9216bc/1040g2sg3134fa3k46m705nmvesrgbjaulu8a5mg!nc_n_webp_mw_1"
                    },{
                    author:"奈奈酱",
                    like:"100+",
                    title:"两个月的布偶猫怎有这么小吗?",
                    img:"https://sns-webpic-qc.xhscdn.com/202406121051/e9e0d308df72d7088a8fcd4cdd90bf8f/1040g2sg313mfvcvk1od05n99ku65h3t2t75jglg!nc_n_webp_mw_1"
                    },{
                    like:"200+",
                    author:"haha",
                    title:"哈哈哈,好可爱的小女孩,打不过...",
                    img:"https://sns-webpic-qc.xhscdn.com/202406121051/d603957a1f4edec9bffaa85cdb72b1e9/1040g0083130o59m670005oo9h6ijonkorh9paeg!nc_n_webp_mw_1"
                    },{
                    title:"这样的礼物你喜欢吗?",
                    img:"https://sns-webpic-qc.xhscdn.com/202406120934/e794f1ff25b0b3492af7becb4c427e91/1040g2sg3134kh5lh6c705o7vonl08qarfhj9s30!nc_n_webp_mw_1",
                    author:"椰子哦",
                    like:"314"
                    },{
                        like:"500+",
                        author:"不懂的茄子",
                        title:"落日好美,你喜欢吗?",
                        img:"https://sns-webpic-qc.xhscdn.com/202406121102/906ea88e8ab9f4481ceb072f8d2b1487/1040g008312onnkkr385g5nqa46lg80uph80gq4o!nc_n_webp_mw_1"
                    }]
                },300)
            }
        }
    }
</script>

<style lang="less">
    Page{
        background-color: aliceblue;
        padding-bottom: 100rpx;
    }
    .list {
        padding: 10rpx;
        column-count: 2;
        box-sizing:content-box;
        padding-right: 30rpx;
        }
    .pbl{
        width: 360rpx;
        break-inside: avoid;
        overflow: hidden;
        border-radius: 10px;
        overflow: hidden;
        margin-bottom: 20rpx;
        background-color: #fff;
        padding: 0 10rpx;
        box-sizing: border-box;
        &:last-child{
            margin-bottom: 10rpx;
        }
        .image{
            width: 100%;
            border-radius: 12rpx;
            overflow: hidden;
            margin-top: 8rpx;
            &>image{
                width: 100%;
                height: 100%;
            }
        }
        
        .title{
            font-size: 30rpx;
            margin-bottom: 6rpx;
            display: -webkit-box;
            text-overflow: ellipsis;
            overflow: hidden;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;//当属性值为3,表示超出3行隐
        }
        .more{
            display: flex;
            justify-content: space-between;
            color: #9499aa;
            margin-bottom: 6rpx;
            font-size: 26rpx;
        }
    }
</style>
相关推荐
FreeTinker2 小时前
HTML本地存储技术解析:localStorage与sessionStorage的原理、差异与应用场景
前端·html
qq_452396232 小时前
第十二篇:《全链路监控与可观测性:前端错误追踪与性能分析》
前端
wangruofeng3 小时前
Phosphor Icons 官网源码拆解:URL 即存储、水波动画与 7362 Star 图标库的架构实践
前端·架构·github
BigTopOne4 小时前
WebRTC Native / Android 开发学习资源整理
前端
excel5 小时前
nuxt 3 升级 nuxt 4 报错之 hasInjectionContext
前端
何以解忧,唯有..5 小时前
LangChain 工具调用(Tool Calling)实战指南
java·前端·langchain
软件聚导航6 小时前
「聚小软 AI 助手」技术升级:从数据库检索到 RAG 知识库问答
前端·数据库·mysql·微信小程序·小程序·ai编程·rag
恋猫de小郭6 小时前
看懂大模型架构术语,帮助你理解目前常见的大模型开源架构
前端·人工智能·ai编程
yma166 小时前
通过提示词实现GitHub Pages 和 Nginx 双部署竟然这么简单?
前端
前端 贾公子6 小时前
第09章:上下文与记忆 (2)
java·服务器·前端