I don't understand twitter bootstrap span and row
Asked Answered
C

1

34

I was a huge 960 grid system user, and I thought I would try out Twitter Bootstrap, but maybe it is a stupid question and you can laugh and down vote me but the fact is I don't understand the span and row.

So my problem is, when I create a container, and create spans inside of it, it does not fit next to each other correctly:

Like in 960gs if i write the following

<div class="container_12">
  <div class="grid_4"></div>
  <div class="grid_4"></div>
  <div class="grid_4"></div>
</div>

I get a perfect 3 column next to each other.

But I cannot achieve this with Twitter Bootstrap, no matter what I do, I always end up with disproportionate columns, so the columns do not fill the container as it supposed to, like with 960gs. If I place 3 columns, then the margin to the right is not correct, or it will not fit correctly in the container.

Boostrap example:

<div class="container">
    <div class="row">
        <div class="span4">
            <h2>Column one</h2>
            <p>
                Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
        </div>  
        <div class="span4">
            <h2>Column one</h2>
            <p>
                Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
        </div>  
        <div class="span4">
            <h2>Column one</h2>
            <p>
                Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
        </div>  
    </div>  
</div>

enter image description here

So in the example above, I end up with disproportionate columns, there is no margin in the first column to the left. If I do this in 960gs with the grid classes it is perfect.

What is different about Twitter Bootstrap when compared to 960gs that is causing my issue?

Craner answered 9/6, 2012 at 15:2 Comment(3)
Can you post the markup that does not work out for you? You can get an explanation of how the grid system works from the documentation page, but we can better answer your question with an example from your own code.Denominational
your code works fine for me with the default bootstrap stylesheet, jsfiddle.net/dyuHM/show, are you modifying the bootstrap in any way?Denominational
i added an image, no i did not edited it in any wayCraner
M
46

The reason:

  • container is 940px
  • row is 960px with a -20px margin
  • span4 300px with a 20px margin

when screen width is <=940px, the -20px from row and the 20px margin from span4 cancel each other out, that's why the first span4 has no left margin.

The 'twitter bootstrap' solution:

Add bootstrap-responsive.css and when the screen goes under 980px and beyond 768px:

container become 724px, row 744px and span4 228px, keeping a left margin on first span4.

Marriott answered 9/6, 2012 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.