css实现简单的瀑布流

这篇博客主要展示了如何利用CSS的`column-count`属性将商品列表分成两列显示,并通过`column-gap`设置列间隙。代码示例中包含了商品图片、信息、价格和详情按钮的布局,同时注意到了避免`column-count`布局错乱的问题。虽然提供的Vue代码中的v-for循环无法运行,但CSS样式是有效的。建议查看完整DEMO以调整循环。
摘要由CSDN通过智能技术生成
flex:

column-count: 2; 规定多少列
column-gap: 5px; 规定列间隙
效果图:
在这里插入图片描述

# 这边这个v-for是运行不了的,但是css样式是ok的,需要看demo先改下这个循环
<div class="flow-goods">
   <div class="flow-goods-item"
        v-for="(item,index) in goodsList.list"
        :key="index">
     <div>
        <van-image height="180"
                   :src="item.thumb" />
            <div class="goods-info">
                <div class="title">{{item.goods_name}}</div>
                <div class="info">{{item.goods_desc}}</div>
                <div class="price">
                     <span class="new-price">¥{{item.price_sell}}</span>
                     <!-- <span class="old-price">¥170</span> -->
                     <!-- <span class="zhe">3.5折</span> -->
                </div>
                <div class="detail-btn">
                     <!-- <span>3.15套米直降30</span> -->
                     <span>详情>></span>
                </div>
            </div>
       </div>
    </div>
</div>
//基于sass
.flow-goods {
    column-count: 2;
    column-gap: 5px;
    padding: 5px;
    .flow-goods-item {
    	height: 100%;
	    overflow: auto;
		/*避免column-count布局错乱*/

        background-color: #fff;
        // break-inside: avoid;
        box-sizing: border-box;
        margin-bottom: 5px;
        & > div {
            display: flex;
            flex-direction: column;
        }
    }





//上面的样式才是核心,下面不用看
    .goods-info {
        padding: 0.2rem;
        .title {
            color: #000;
            font-size: 0.8rem;
            text-overflow: -o-ellipsis-lastline;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }
        .info {
            color: #ccc;
            width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .price {
            .new-price {
                color: $color;
                font-size: 20px;
            }
            .old-price {
                margin-left: 0.2rem;
                text-decoration: line-through;
            }
            .zhe {
                border: 1px solid $color;
                color: $color;
                margin-left: 0.8rem;
            }
        }
        .detail-btn {
            display: flex;
            justify-content: space-between;
            align-items: center;
            & > span:first-child {
                background-color: $color;
                color: #fff;
                border-radius: 1rem;
                padding: 0.1rem 0.5rem;
            }
            & > span:last-child {
                background-color: rgb(255, 102, 0);
                color: #fff;
                border-radius: 5px;
                padding: 0 2px;
            }
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

开发路上的AZhe

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值