zoukankan      html  css  js  c++  java
  • 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- 500px) { 
                    .masonary { flex-direction: row; } 
                }
                
                .clumn{
                    margin-left: 0.5rem;
                    display: flex; 
                    flex-flow: column wrap; 
                    width: 100%;
                }
                @media only screen and (max- 500px) { 
                    .clumn { width: 100%;max-width: 95%;margin: auto; } 
                }
                
                .clumn>.item>.item__content{
                    margin-bottom: 0.5rem;
                    color: white;
                    text-align: center;
                }
  • 相关阅读:
    职业生涯规划
    Java中double函数,四舍五入并保留小数点后两位的4种方法,BMI案例
    获取request.getSession().setAttribute()的值【详解加案例】
    Mac 如何安装Homebrew?
    XCode6的iOS Simulator 文件保存位置
    iOS8无法弹出本地通知?
    Xcode如何找到默认的生成路径?
    Android 实现简单音乐播放器(二)
    Android 实现简单音乐播放器(一)
    Android 如何实现带滚动条的TextView,在更新文字时自动滚动到最后一行?
  • 原文地址:https://www.cnblogs.com/famLiu/p/7477474.html
Copyright © 2011-2022 走看看