46.纯css实现瀑布流(flex)

效果图

HTML

<div class="masonary">
            <div class="clumn">
                <div class="item"> 
                    <div class="item__content" style="height: 100px;background: lightblue;">1 </div> 
                    <div class="item__content" style="height: 210px;background: orange;"> 2</div> 
                    <div class="item__content" style="height: 110px;background: lightcoral;">3 </div> 
                    <div class="item__content" style="height: 170px;background: lightgray;"> 4</div> 
                    <div class="item__content" style="height: 100px;background: lightblue;">5 </div> 
                    <div class="item__content" style="height: 180px;background: lightsteelblue;">6 </div> 
                </div>
            </div>
            <div class="clumn">
                <div class="item"> 
                    
                    <div class="item__content" style="height: 100px;background: lightblue;"> 7</div> 
                    <div class="item__content" style="height: 120px;background: lightsteelblue;">8</div> 
                    <div class="item__content" style="height: 60px;background: orange;"> 9</div> 
                    <div class="item__content" style="height: 200px;background: orange;">10 </div> 
                    <div class="item__content" style="height: 100px;background: lightcoral;">11 </div> 
                    <div class="item__content" style="height: 260px;background: lightgray;">12 </div> 
                </div>
            </div>
            <div class="clumn">
                <div class="item"> 
                    <div class="item__content" style="height: 130px;background: lightcyan;">13 </div> 
                    <div class="item__content" style="height: 199px;background: orange;">14 </div> 
                    <div class="item__content" style="height: 160px;background: lightcoral;">15 </div> 
                    <div class="item__content" style="height: 146px;background: orange;">16 </div> 
                    <div class="item__content" style="height: 160px;background: lightcoral;">17 </div> 
                    <div class="item__content" style="height: 111px;background: orange;">18 </div> 
                </div>
            </div>
        </div>

css

.masonary{
                width: 100%;
                max-width: 1000px;
                margin: auto;
                display: flex;
                flex-direction: column;
                height: auto;
            }
            @media only screen and (min-width: 500px) { 
                .masonary { flex-direction: row; } 
            }
            
            .clumn{
                margin-left: 0.5rem;
                display: flex; 
                flex-flow: column wrap; 
                width: 100%;
            }
            @media only screen and (max-width: 500px) { 
                .clumn { width: 100%;max-width: 95%;margin: auto; } 
            }
            
            .clumn>.item>.item__content{
                margin-bottom: 0.5rem;
                color: white;
                text-align: center;
            }

 

转载于:https://www.cnblogs.com/famLiu/p/7477474.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值