Fullwidth and multiple columns using flexbox

后端 未结 1 1139
南旧
南旧 2020-12-11 17:17

I\'m trying to create a flexbox row with fullwidth and multiple columns on the same container.

I\'ve tried flex-break: after; but am not su

相关标签:
1条回答
  • 2020-12-11 18:09

    You need to set flex-wrap: wrap on flex container, and then flex: 0 0 100% on full-width items and flex: 0 0 50% on half-width items. Also you should add box-sizing: border-box.

    * {
      box-sizing: border-box;
    }
    .collage {
      display: flex;
      flex-wrap: wrap;
    }
    .collage-item {
      border: 1px solid black;
      flex: 0 0 50%;
      padding: 10px;
    }
    .fullwidth {
      flex: 0 0 100%;
    }
    <div class="collage">
      <!-- fullwidth -->
      <div class="collage-item fullwidth">a</div>
    
      <!-- two columns -->
      <div class="collage-item">b</div>
      <div class="collage-item">c</div>
    
      <!-- fullwidth -->
      <div class="collage-item fullwidth">d</div>
    </div>

    0 讨论(0)
提交回复
热议问题