Rearranging responsive Bootstrap 4 grid layout

前端 未结 1 1666
甜味超标
甜味超标 2021-01-26 13:00

Let\'s say you have a page with four main blocks in it (they would each contain varying amounts of content):

相关标签:
1条回答
  • 2021-01-26 13:34

    Basically this has been asked before. There is a way with Bootstrap 4, but you need to use floats instead of flexbox.

    Here d-sm-block is used to apply the floats only on sm and wider. Flexbox is used for mobile which allows the ordering to work.

    <div class="row d-sm-block">
        <div class="col-sm-9 order-2 order-md-0 float-left">2</div>
        <div class="col-sm-3 order-3 order-md-0 float-right">3</div>
        <div class="col-sm-3 order-1 order-md-0 float-right">1</div>
        <div class="col-sm-3 order-4 order-md-0 float-right">4</div>
    </div>
    

    Demo: https://www.codeply.com/go/ksaw8Aq2lP

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