Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of using multiple bootstrap column sizes?

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?

like image 200
o_in25 Avatar asked Aug 20 '15 04:08

o_in25


People also ask

Why does Bootstrap use 12 columns?

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.

What is the purpose of container row and column in Bootstrap framework?

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 Bootstrap columns allow?

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.

How many columns does a Bootstrap layout use?

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.


1 Answers

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>
like image 80
Steve Sanders Avatar answered Sep 28 '22 02:09

Steve Sanders