Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap responsive grid changing order of columns when displayed on mobile with rows?

----------------------
A   |    B     |   C
----------------------

when scaled to mobile I will expect:

-------
   B
-------
   A
-------
   C

Is it possible with new in Bootstrap3 push option?

I was trying

<div class="row">
    <div class="col-xs-12 col-sm-3 col-sm-push-6" style="background-color:red">
        A
    </div>

    <div class="col-xs-12 col-sm-6 cols-sm-pull-3 no-col-padding">
    <center>
          B
    </center>
    </div>

    <div class="col-xs-12 col-sm-3" style="background-color:pink">
         C
    </div>
</div>
like image 707
andilabs Avatar asked Jul 12 '14 18:07

andilabs


People also ask

How do I change the order of 5 columns in Bootstrap mobile?

We can easily change the order of built-in grid columns with push and pull column classes. The Push and Pull Classes: The push class will move columns to the right while the pull class will move columns to the left.

How do I change Bootstrap 3 column order on mobile layout?

By default, this will display the main content first. So in mobile, the main content will be displayed first. Try using col-lg-push and col-lg-pull to reorder the columns in large screens and display the sidebar on the left and main content on the right.

How do I order columns in Bootstrap?

Bootstrap 4.1+ Since Bootstrap 4 is flexbox, it's easy to change the order of columns. The cols can be ordered from order-1 to order-12 , responsively such as order-md-12 order-2 (last on md , 2nd on xs ) relative to the parent . row . It's also possible to change column order using the flexbox direction utils...

How do I swap columns in Bootstrap?

To move columns to the right, use the . col-*-offset-* class in Bootstrap.


1 Answers

See this question

  • col-vp-push-x = push the column to the right by x number of columns, starting from where the column would normally render -> position: relative, on a vp or larger view-port.

  • col-vp-pull-x = pull the column to the left by x number of columns, starting from where the column would normally render -> position: relative, on a vp or larger view-port.

    vp = xs, sm, md, or lg

    x = 1 thru 12

I think what messes most people up, is that you need to change the order of the columns in your HTML markup (in the example below, B comes before A), and that it only does the pushing or pulling on view-ports that are greater than or equal to what was specified. i.e. col-sm-push-5 will only push 5 columns on sm view-ports or greater.

  • (Desktop) Larger view-ports get pushed and pulled.
  • (Mobile) Smaller view-ports render in normal order.

DEMO

<div class="row">
    <div class="col-sm-5 col-sm-push-5">
        Content B
    </div>
    <div class="col-sm-5 col-sm-pull-5">
        Content A
    </div>
    <div class="col-sm-2">
        Content C
    </div>
</div>

View-port >= sm

|A|B|C|

View-port < sm

|B|
|A|
|C|
like image 196
Schmalzy Avatar answered Sep 21 '22 13:09

Schmalzy