Bootstrap right Column on top on mobile view

前端 未结 11 2114
逝去的感伤
逝去的感伤 2020-11-28 17:51

I have a Bootstrap Page like this:

A
相关标签:
11条回答
  • 2020-11-28 18:17

    Bootstrap 4 includes classes for flex. See: https://getbootstrap.com/docs/4.3/layout/utilities-for-layout/

    <div class="row flex-column-reverse flex-md-row">
        <div class="col-sm-10">
            Col 1
        </div>
        <div class="col-sm-2">
           Col 2
        </div>
    </div>
    
    0 讨论(0)
  • 2020-11-28 18:21

    In Bootstrap 4, let's say you want to have one order for large screens and a different order for smaller screens:

    <div class="container">
      <div class="row">
        <div class="col-6 order-1 order-lg-2">
          This column will be ordered second on large to extra large screens
        </div>
        <div class="col-6 order-2 order-lg-1">
          This column will be ordered first on large to extra large screens
        </div>
      </div>
    </div>
    

    You can omit order-1 and order-2 above. Just added for clarity. Default order will be the order the columns appear in the html.

    For more info https://getbootstrap.com/docs/4.1/layout/grid/#reordering

    0 讨论(0)
  • 2020-11-28 18:24

    I used:

    .row {
       display: flex;
       flex-direction: row-reverse;
    }
    
    0 讨论(0)
  • 2020-11-28 18:26

    I have three bootstrap 4 columns of different sizes. As the screen gets smaller the third column is hidden, then when the screen gets smaller still and the divs are stacked the order changes so that column 2 is at the top.

        <div class="col-xs-12 col-sm-4 col-md-3 order-2 order-sm-1">
            <h3>LEFT HAND SECTION</h3>
            <p>For news, links photos or comments.</p>
        </div>
        <div class="col-xs-12 col-sm-8 col-md-5 order-1 order-sm-2">
            <h3>MAIN SECTION</h3>
            <p>The main content for the page.</p>
        </div>
        <div class="col-xs-12 col-md-4 d-none d-md-block order-last">
            <h3>BLANK SECTION</h3>
            <p>Will usually just be blank.</p>
        </div>
    

    I hope this helps. I found it difficult to understand this but finally got there with the help of this thread, but it was a bit hit and miss.

    0 讨论(0)
  • 2020-11-28 18:31

    In Bootstrap V4 (Released January 18, 2018) You can use Reordering Classes. Info here under Reordering tab.

    https://getbootstrap.com/docs/4.0/layout/grid/

    0 讨论(0)
  • 2020-11-28 18:34

    Use Column ordering to accomplish this.

    col-md-push-6 will "push" the column to the right 6 and col-md-pull-6 will "pull" the column to the left on "md" or greater view-ports. On any smaller view-ports the columns will be in normal order again.

    I think what throws people off, is that you have to put B above A in your HTML. There may be a different way to do this where A can go above B in the HTML, but I'm not sure how to do it...

    DEMO

    <div class="row">
      <div class="col-md-6 col-md-push-6">B</div>
      <div class="col-md-6 col-md-pull-6">A</div>
    </div>
    

    view-port >= md

    |A|B|
    

    view-port < md

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