纯css制作瀑布流样式

在制作瀑布流格式的时候,一开始没有发现这个问题,当我只有两行的时候,每相隔一个div的大小一样的时候,我发现我的第一列的div一小部分内容跑到第二列中去了,这使我 很无解,目前我还没有想到解决的方法用瀑布流的写法,用js进行布局倒是可以解决这个问题。

这是我的代码 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>瀑布流格式</title>
    <style>
    .contain{
        width: 500px;
        height: 600px;
        overflow: hidden;
        overflow-y: scroll;
        margin: auto;
        column-count: 2;
	    -webkit-column-count: 2;
	    -moz-column-count: 2;
    }
    .item{
        width: 240px;
        height: 100px;
        background: saddlebrown;
        margin-bottom: 2px;
    }
    </style>
</head>
<body>
    <div class="contain">
        <div class="item" style="height: 100px"></div>
        <div class="item" style="height: 80px"></div>
        <div class="item" style="height: 100px"></div>
        <div class="item" style="height: 80px"></div>
        <div class="item" style="height: 100px"></div>
        <div class="item" style="height: 80px"></div>
        <div class="item" style="height: 100px"></div>
        <div class="item" style="height: 80px"></div>
        <div class="item" style="height: 100px"></div>
        <div class="item" style="height: 80px"></div>
    </div>
</body>
</html>

这是我的效果图:

我在尝试用css来解决这个问题,如果大家有什么好的建议,请大家能告诉我一下,我也学习一下。谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值