Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice for single column within row in bootstrap v3 grid system?

I've read about the grid system here: http://getbootstrap.com/css/#grid. While the documentation doesn't directly address a scenario in which there's one column within a row, I do see one example of this here: http://getbootstrap.com/css/#grid-offsetting > third row of the example code.

Currently, I'm applying the class .col-xs-12 to the one column within the containing tags and it is working well across all viewport dimensions. However, I want to ensure there isn't a better way to do this.

Thanks!

like image 970
user2788141 Avatar asked Sep 17 '13 16:09

user2788141


People also ask

How many columns fit in a single row in the Bootstrap grid system?

The Bootstrap grid has only 12 columns, so you should never have more than 12 columns in a row. You should have only 3 col-md-4 in each .

Is nested column possible with Bootstrap grid system?

You can nest columns once you have a container, row, and column set up. To do this, add a new row <div> within the parent column's code, then add your nested columns. It will function as if the area inside the new row is its own grid system.

How many columns can Bootstrap incorporate in a row?

There are 12 template columns available per row, allowing you to create different combinations of elements that span any number of columns. Column classes indicate the number of template columns to span (e.g., col-4 spans four).

How many columns are allowed in a Bootstrap grid system 1 point?

Bootstrap's grid system allows up to 12 columns across the page.


1 Answers

I think adding a col*-12 will be the best practice. It will make all rows in your grid act the same.

Example:

enter image description here

html

<div class="container">             <div class="row" style="background-color:yellow;">                 <div class="col-xs-12" style="background-color:aqua;">col-xs-12 inside a row</div>             </div> </div>                       <div class="container">             <div class="row" style="background-color:yellow;">                 direct inside a row             </div> </div>       <div class="container">             <div class="row" style="background-color:yellow;">                 <div class="col-xs-6" style="background-color:red;">col-xs-6 inside a row</div>                 <div class="col-xs-6" style="background-color:orange;">col-xs-6 inside a row</div>             </div> </div> 

As you see the content is NOT in line with the other rows when you don't add a col-*-12 (due to the missing padding). All the rows the same will make future changes easier.

You will have to notice the col*-12 columns differs from the other col-- cause the don't have a float left, see: https://github.com/twbs/bootstrap/issues/10152

like image 132
Bass Jobsen Avatar answered Oct 27 '22 05:10

Bass Jobsen