Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between push and offset under the grid system?

I'm trying to understand the difference between push and offset in Bootstrap grids. For example the only difference between the two rows below is the third column in each. One uses a push and the other uses an offset. However, they both render exactly the same.

<div class="row">     <div class="col-md-2">         <h2>Column 1</h2>         <p>             This is text for column 1         </p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>     </div>     <div class="col-md-2">         <h2>Column 2</h2>         <p>This is text for column 2</p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>     </div>     <div class="col-md-2 col-md-push-6">         <h2>Column 3</h2>         <p>This is text for column 3</p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>     </div> </div>  <div class="row">     <div class="col-md-2">         <h2>Column 1</h2>         <p>             This is text for column 1         </p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>     </div>     <div class="col-md-2">         <h2>Column 2</h2>         <p>This is text for column 2</p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>     </div>     <div class="col-md-2 col-md-offset-6">         <h2>Column 3</h2>         <p>This is text for column 3</p>         <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>     </div> </div> 
like image 387
Randy Minder Avatar asked Apr 01 '14 17:04

Randy Minder


People also ask

What is offset in grid?

An offset is used to push columns over for more spacing. To use offsets on large displays, use the . col-md-offset-* classes.

What is the grid system in Bootstrap?

Bootstrap's grid system uses a series of containers, rows, and columns to layout and align content. It's built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.

How many classes are available in the grid system?

Grid Classes The Bootstrap 4 grid system has five classes: . col- (extra small devices - screen width less than 576px)

What is XS SM MD lg in Bootstrap?

The Bootstrap 3 grid system has four tiers of classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops). You can use nearly any combination of these classes to create more dynamic and flexible layouts.


1 Answers

Since offset uses margin-left, and push uses left:

  • offset will force neighboring columns to move
  • push (and pull) will overlap other columns

Here's a visual example: http://www.bootply.com/126557

In your example there are no column 'collisions'. Push and offset appear the same since the neighbouring columns aren't impacted.

like image 90
Zim Avatar answered Sep 29 '22 14:09

Zim