Prevent element fragmentation in multi-column layout

前端 未结 2 1728
孤街浪徒
孤街浪徒 2021-01-13 13:20

Given this code:



        
2条回答
  •  天涯浪人
    2021-01-13 14:04

    Probably using -webkit-column-break-after: always; with the FIRST BOX is appropriate.

    FIRST BOX: ...
    SECOND BOX: ...
    THIRD BOX: ...

    And this CSS code:

    #wrapper { 
        border:2px solid red;
        padding:10px;
        width:310px; 
        //height:310px;
        -webkit-column-width:150px; -webkit-column-gap:10px;
        -moz-column-width:150px; -moz-column-gap:10px;
        column-width:150px; column-gap:10px;
    }
    
    #wrapper > div { 
        width:150px;
        background:#ccc;
        margin-bottom:10px;
    }
    #wrapper > div:first-child {
       -webkit-column-break-after: always;
    }
    

提交回复
热议问题