Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my Bootstrap push & pull divs not working?

I want to have 2 divs besides each other for col-md and higher, while having them above each other for col-sm and lower. So I tried to use the push and pull feature as mentioned in the docs but somehow it's not working. What I'm trying to do is get the RIGHT div above the LEFT div on col-sm and lower, basically reversing the order.

What am I doing wrong?

<div class="container">
  <div class="row">
    <div class="col-sm-12 col-sm-push-12 col-md-7">LEFT</div>
    <div class="col-sm-12 col-sm-pull-12 col-md-5">RIGHT</div>
  </div>
</div>

Here's a fiddle: https://jsfiddle.net/ko7euh77/1/

like image 237
user1996496 Avatar asked Sep 18 '16 16:09

user1996496


People also ask

What does md mean in Bootstrap?

The Bootstrap v4 grid system has five tiers of classes: xs (extra small), sm (small), md (medium), lg (large), and xl (extra large). You can use nearly any combination of these classes to create more dynamic and flexible layouts.

What is sm md lg in Bootstrap?

The Bootstrap grid system has four classes: xs (for phones - screens less than 768px wide) sm (for tablets - screens equal to or greater than 768px wide) md (for small laptops - screens equal to or greater than 992px wide) lg (for laptops and desktops - screens equal to or greater than 1200px wide)


1 Answers

You just need to think "mobile-first"..

<div class="container">
  <div class="row">
    <div class="col-sm-12 col-md-push-7 col-md-5">RIGHT</div>
    <div class="col-sm-12 col-md-pull-5 col-md-7">LEFT</div>
  </div>
</div>

Demo: http://www.codeply.com/go/2SN4r7KGwV


Bootstrap 4 Update

The push pull class are now order-* (using flexbox) in Bootstrap 4.

https://www.codeply.com/go/l3BOOH6JM9

<div class="row">
    <div class="col-md-5 order-md-2">
        <div class="card card-body">RIGHT</div>
    </div>
    <div class="col-md-7 order-md-1">
        <div class="card card-body">LEFT</div>
    </div>
</div>
like image 114
Zim Avatar answered Sep 20 '22 21:09

Zim