Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter bootstrap - nesting rows vs multiple rows

I started to use Twitter bootstrap for this application that I am working on.

I read the documentation about nesting rows in both fixed grid system and in fluid one.

Now, I want to do something like this

enter image description here

So of course I could do something like this

<div class="container">
    <div class="row">
        <div class="span 12">red</div>
        <div class="row">
            <div class="span 3">yellow</div>
            <div class="span 9">green</div>
        </div>
    </div>
</div>

and I think I would get what I want. But I am wondering what are the consequences of doing

<div class="container">
    <div class="row">
        <div class="span 12">red</div>
    </div>
    <div class="row">
        <div class="span 3">yellow</div>
        <div class="span 9">green</div>
    </div>
</div>

I don't see any difference now in my browser but I am wondering what will happen if I include multiple row elements in single container tag. Is the row-nesting the only proper way to create something like I showed? What is the difference between those two implementations of my design, so to speak?

like image 799
Andna Avatar asked Mar 24 '13 21:03

Andna


People also ask

Is Bootstrap always 12 columns?

Bootstrap uses a 12-column grid system that can update itself responsively based on screen size. There are only 38 highly composite numbers below the one million threshold, including 120, 2520, 5040, 55440 and 720720.

When should I use rows in Bootstrap?

Use rows to create horizontal groups of columns. Content should be placed within columns, and only columns may be immediate children of rows.

Can you nest rows in Bootstrap?

You can easily nest grids using bootstrap by adding additional rows.

Is nested columns 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.


1 Answers

The second version is more correct. But both work. The difference is how it responds when the page is re-sized. The second version will shrink and react better

However if you want the containers to match the above image you need to use class="container-fluid" and class="row-fluid"

Also remove the spaces between the spans and numbers

class="span 3"

Should say

class="span3"
like image 175
MLewisCodeSolutions Avatar answered Sep 19 '22 11:09

MLewisCodeSolutions