瀑布流

本文详细介绍并演示了如何使用CSS3的column-count属性实现多列瀑布流布局,通过具体代码示例展示了不同高度元素在多列间均匀分布的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://www.cnblogs.com/fuhuixiang/p/4340205.html

    column-count:3;
 

https://www.zhangxinxu.com/wordpress/2017/02/css3-multiple-column-layout-read-horizontal/

https://www.cnblogs.com/xinjie-just/p/5953386.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <style>
        body {
            margin: 0;
        }
        .waterfall-container {
            /*分几列*/
            column-count: 2;
            width: 100%;
            column-gap: 10px; /* column-gap: 列与列间的间隙 */
        }

        .waterfall-item {
            break-inside: avoid;
            width: 100%;
            height: 100px;
            margin-bottom: 10px;
            background: #ddd;
            column-gap: 0;
            text-align: center;
            color: #fff;
            font-size: 40px;
        }
    </style>
</head>
<body>
<div class="waterfall-container">
    <div class="waterfall-item" style="height: 100px">1</div>
    <div class="waterfall-item" style="height: 300px">2</div>
    <div class="waterfall-item" style="height: 400px">3</div>
    <div class="waterfall-item" style="height: 100px">4</div>
    <div class="waterfall-item" style="height: 300px">5</div>
    <div class="waterfall-item" style="height: 600px">6</div>
    <div class="waterfall-item" style="height: 400px">7</div>
    <div class="waterfall-item" style="height: 300px">8</div>
    <div class="waterfall-item" style="height: 700px">9</div>
    <div class="waterfall-item" style="height: 100px">10</div>
</div>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值