I have much love for Bootstrap by Twitter. But there are some things that I was slow to figure out, see my earlier post on this: How to style Rows in Bootstrap.
Similarly to the style issue, you can’t easily add padding to elements within a row. Say you want to to have a row that has multiple columns. But you need to have a 15px padding for each column. (The row has a styled background and we don’t want the columns to touch the edges). If you try and target your columns directly via the .spanXX class with a descendant selector, you’ll have headaches later on when you change your column width, or add another row that had different needs. (I should mention, this isn’t a unique problem to Bootstrap. Most, if not all, grid systems have this issue.)
The solution is to place a <div> element within the .spanXX column container. This div is then padded and your content is then placed within.
Nice and simple:
<div class="row"> <div class="span6"> <div class="extraneous-non-semantic-markup"> <p>Your Content is Padded!</p> </div> </div> <div class="span6"> <div class="extraneous-non-semantic-markup"> <p>Yay!</p> </div> </div> </div>
And the styling on the class:
.extraneous-non-semantic-markup {
padding: 15px
}
And that feels so dirty. But it’s a compromise that works because we gain so much more from grid layouts.




