Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column ordering bootstrap

I have a bootstrap layout like this:

<div class="row">
    <div class="col-md-2">
    1
    </div>
    <div class="col-md-8">
    2
    </div>  
    <div class="col-md-2">
    3
    </div>
</div>

It looks like this:

1 2 3

On mobile device, column 1 is on top, which is what I want, but then I want 3 column to appear the second and then 2 column to be third.

Is this possible?

like image 893
Emily Avatar asked Dec 04 '18 14:12

Emily


People also ask

How do I order columns in Bootstrap?

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 change the order of 5 columns in Bootstrap mobile?

On small screens(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 4 column order on mobile layout?

To do this, you would need to set the source code to be in the order you want it to be on mobile. Then add the order classes to the columns specifying the order at the breakpoint you choose. In our case we want SM and up. Using Bootstrap's order classes you can essentially move columns around like a forklift.

How do I change the order of columns in Bootstrap 3?

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.


1 Answers

You can use the classes defined by bootstrap (https://getbootstrap.com/docs/4.1/utilities/flex/#order) like below

.row > div {
 border:2px solid;
 text-align:center;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="container">
  <div class="row">
    <div class="col-md-2 order-0 order-md-0">
      1
    </div>
    <div class="col-md-8 order-2 order-md-1">
      2
    </div>
    <div class="col-md-2 order-1 order-md-2">
      3
    </div>
  </div>
</div>
like image 150
Temani Afif Avatar answered Sep 30 '22 09:09

Temani Afif