How to Change Column Order with Bootstrap 4
With Bootstrap column ordering it is best to start out understanding how the natural or default column ordering works. When your browser reads your HTML code it reads from the top and works its way down reading left to right. So in a two column grid, the first column will be the first one it finds under the .row class.
A web browser reads code from the top down
Remember Mobile first
There is no .push-xs-6 class because Bootstrap is a mobile first framework. What is mobile first? It basically means the HTML and CSS you first send to the browser are for mobile devices. So you should write your HTML markup in the order you want it show up on mobile. Then use the push pull classes to rearrange things on larger devices like a forklift moves boxes around..
Below is the result of the code above.
A two column grid with the images 100% width of the column.
Now, how would you make B column swap positions with A column?
Using Bootstrap’s push and pull classes you can essentially move columns around like a forklift.
<h2>With column ordering</h2>
<div class="row">
<div class="col-sm-6 push-sm-6">
<img src="https://dummyimage.com/400x400/000/fff&text=A" alt="" class="w-100" />
</div>
<div class="col-sm-6 pull-sm-6">
<img src="https://dummyimage.com/400x400/000/fff&text=B" alt="" class="w-100" />
</div>
</div>.push-sm-6
Add this class to first column to push it 6 columns to the right. Remember Bootstrap is based on a 12 point grid system.
.pull-sm-6
Now add this class to the second column to move the column to the left 6 spots.
Get Jacob Lett’s stories in your inbox
Join Medium for free to get updates from this writer.
So our two column grid still equals 12 total columns.
Conclusion
The most important thing to remember is the Bootstrap CSS Framework is mobile first. Write your markup how you want it to be displayed on mobile devices. Then apply the push and pull classes to reorder things at different breakpoints. Always keeping in mind your push pull classes need to add up to 12 columns.
Like this? Please click ❤ below so other people can find it. Thank you!










