I'm fairly new to Bootstrap, and I understand how Bootstrap uses a 12-column grid. When I want to make utilize a Bootstrap grid, I traditionally do it like this:
<div class="row">
<div class="col-md-6">
...
</div>
<div class="col-md-6">
...
</div>
</div>
I also understand that different column sizes are used for different screen sizes
<div class="row">
<div class="col-xs-6">
...
</div>
<div class="col-xs-6">
...
</div>
</div>
However, I've seen a lot of people do something similar to this:
<div class="row">
<div class="col-xs-6 col-md-6 col-lg-6">
...
</div>
<div class="col-xs-6 col-md-6 col-lg-6">
...
</div>
</div>
Why use multiple column sizes? Will the browser detect which one is appropriate to use?
Most versions of Bootstrap only use 12 columns to account for the following: Easier layout creation. Responsive layout for mobile devices. Proportional "blocks" to keep everything symmetrical.
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.
Rows also support modifier classes to uniformly apply column sizing and gutter classes to change the spacing of your content. Columns are incredibly flexible. There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns.
You can use a maximum of 12 columns in a Bootstrap grid system. 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 explanation for how the grid system comes together.
There is absolutely no reason to have all three classes in this example:
<div class="row">
<div class="col-xs-6 col-md-6 col-lg-6">
...
</div>
<div class="col-xs-6 col-md-6 col-lg-6">
...
</div>
</div>
It is effectively the same as this:
<div class="row">
<div class="col-xs-6">
...
</div>
<div class="col-xs-6">
...
</div>
</div>
Bootstrap grid classes work on all sizes above the size specified, so applying col-xs-6
will cause that element to also contain 6 columns on any larger screen sizes, like sm, md, etc. I'm guessing that whoever is including all three classes in the first example does not have a firm understanding of how the Bootstrap grid system works.
You only need to include multiple classes if you want the element to be a different size on different screen sizes:
<div class="row">
<div class="col-xs-4 col-md-3 col-lg-2">
...
</div>
<div class="col-xs-8 col-md-9 col-lg-10">
...
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With