I am having trouble understanding the Twittter Bootstrap framework. Does it allow for basic padding around containers?
There seems to be a default 20px margin left but no padding. Anyone here managed to solve this issue?
http://twitter.github.com/bootstrap/
This works fine if your background is white but the moment I place a color behind a container, I get no padding and if I add padding, my layout breaks. Am I doing something wrong?
Taking the above approach and applying it to padding would also work.
Add a class called .is-padded to the span that you want to padd (in this case span4)
<!-- Example row of columns -->
<div class="row">
<div class="span4 is-padded">
<h2>Heading</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>
<p><a class="btn" href="#">View details »</a></p>
</div>
</div>
Then create CSS (or less) that reduces the width of the span by the applied padding, for example:
/* CSS example */
.span4.is-padded {
width: 280px; /* 300 - (10x2) */
padding: 10px;
background: #CCC; /* just so you can see it */
}
/* Less example */
.span4.is-padded {
width: (@gridColumnWidth * 4) + (@gridGutterWidth * 3) - @gridGutterWidth;
padding: @gridGutterWidth/2;
background: #CCC; /* just so you can see it */
}
This can easily be repeated for the rest of the grid
.is-padded {
padding: @gridGutterWidth/2;
background: #CCC; /* just so you can see it */
}
.span1.is-padded {
width: (@gridColumnWidth * 1) + (@gridGutterWidth * 0) - @gridGutterWidth;
}
.span2.is-padded {
width: (@gridColumnWidth * 2) + (@gridGutterWidth * 1) - @gridGutterWidth;
}
.span3.is-padded {
width: (@gridColumnWidth * 3) + (@gridGutterWidth * 2) - @gridGutterWidth;
}
.span4.is-padded {
width: (@gridColumnWidth * 4) + (@gridGutterWidth * 3) - @gridGutterWidth;
}
... etc
The break points in the responsive grids can easily be overridden also using media queries.
This approach will not work in fluid grids though.