search

Home  >  Q&A  >  body text

html - flex布局,如何实现9宫格列表两端对齐

如图所以,用flex布局方式,如何让热门应用的的右端与边框对齐,达到两端对齐的效果,因为是循环列表,不是单行,不知道该如何控制,请大神指点一下!

伊谢尔伦伊谢尔伦2782 days ago1259

reply all(8)I'll reply

  • 高洛峰

    高洛峰2017-04-17 12:02:25

    It is better to teach a man to fish than to teach him to fish.
    flex layout

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 12:02:25

    Set display:flex on the outermost p; then set styles on three p’s inside

    .row{
        display: flex;
        width: 100%;
    }
    .col-33{ 
        flex: 0 0 33.3%; 
        max-width: 33.3%; 
        }
    .text-center{
        text-align:center;
    }   
    <p>
        <p class="col-33 text-left"></p>
        <p class="col-33 text-center"></p>
        <p class="col-33 text-right"></p>
    </p>

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 12:02:25

    Use justify-content: space-between; on the container to align both sides

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 12:02:25

    The parent container uses justify-content: space-between; to align both ends, and the space between items is equal!
    You can refer to this

    justify-content : 在主轴上的对齐方式
                        flex-start    做对齐
                        flex-end    右对齐
                        center        居中
                        space-between    两端对齐,项目之间的间隔都相等
                        space-around     每个项目两侧的间隔相等,所以,项目之间的间隔要大与与边框的距离
    

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 12:02:25

    This scenario is more suitable for layout using percentage width instead of flex. Any layout has its limitations and must be used flexibly. If there are 3, set width:33.33%

    reply
    0
  • 迷茫

    迷茫2017-04-17 12:02:25

    One more thing, if you want to use flex on the mobile side, it is recommended to only use the flex attribute.
    You can refer to Taobao’s approach, use flex and box together, reference link: http://h5.m.taobao.com/mlapp/...

    Other references:
    https://css-tricks.com/old-fl...
    https://www.html5rocks.com/en...

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 12:02:25

    flex version: detailed explanation of various layouts of web pages

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 12:02:25

    The parent element sets display:flex;
    The child element sets justify-content: space-between;

    reply
    0
  • Cancelreply