Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3: Offset isn't working?

I have this code:

<div class="row">
  <div class="col-sm-3 col-sm-offset-6 col-md-12 col-md-offset-0"></div>
  <div class="col-sm-3 col-md-12"></div>
</div>

What I want for small (sm) screens is to have two divs that have three columns each, and an offset of 6 columns for the first div.

For medium (md) screens, I would like to have two divs with twelve columns each (one horizontally stacked under the other), with no offsets.

Somehow the browser doesn't recognize the class col-md-offset-0. It still uses the col-sm-offset-6 class. Any ideas why?

like image 442
David Avatar asked Mar 21 '14 13:03

David


People also ask

Why offset is not working?

The reason why it doesn't work is due to using the col-*-offset-* class in bootstrap 4 or a later version. Since bootstrap 4, the col-*-offset-* class was replaced with offset-*-* where the first * is the responsiveness (sm, md, lg, etc) and the second * is the number of columns (eg.

What is offset 3 in bootstrap?

offset-md-3 which will offset the desired column element with 3 columns to the right from its default position on medium screen sizes and above. . offset classes always shifts its content to the right. This all stuff produced results .

How offset works bootstrap?

Offsets are used for spacing elements in the responsive grid. The unit is based on the column layout. Means that in the medium range of the grid system, the element will have a width of 6 colums and there will be 3 blank columns before the element (and as a consequence, will have 3 blank colums after).


1 Answers

Which version of bootstrap are you using? The early versions of Bootstrap 3 (3.0, 3.0.1) didn't work with this functionality.

col-md-offset-0 should be working as seen in this bootstrap example found here (http://getbootstrap.com/css/#grid-responsive-resets):

<div class="row">
   <div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
   <div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2 .col-md-6 .col-md-offset-0</div>
</div>
like image 90
Overachiever Avatar answered Sep 30 '22 00:09

Overachiever