I've only just started working with bootstrap and unsure about how to achieve my goal.
I would like the gutters to all be even, like they are in this image:
by default, they look like this, the vertical gutters in between columns (marked with blue) are double the horizontal and outside gutters:
Any help on the best way to solve this probably would be appreciated.
try:
Every column have a padding of 15 px on both sides. Which makes a gutter between of 30 px. In the case of the sm-grid your container class will 970px (((940px + @grid-gutter-width))). Every column get a width of 940/12. The resulting @grid-gutter-width/2 on both sides of the grid will be hide with a negative margin of - 15px;. Undoing this negative left-margin set a gutter of 30 px on both sides of the grid. This gutter is build with 15px padding of the column + 15 px resting grid space.
update
In response of the answer of @ElwoodP, consider the follow code:
In the case of nesting, manipulation the .row class indeed influences the sub grid. Good or fault depends on your expectations / requirements for the subgrid. Changing the margin of the
.row
won't break the sub grid.default:
margin of the
.row
classwith:
padding of the
.container
classwith:
Notice sub grids shouldn't wrapped inside a
.container
class.@Bass Jobsen and @ElwoodP attempted to answer this question in reverse--giving the outer margins the same DOUBLE size as the gutters. The OP (and me, as well) was searching for a way to have a SINGLE size gutter in all places. Here are the correct CSS adjustments to do so:
This leaves a
14px
gutter and outside margin in all places.Add these helper classes to the stylesheet.less (you can use http://less2css.org/ to compile them to CSS )
And here’s how you can use it in your HTML:
If you use sass in your own project, you can override the default bootstrap gutter size by copy pasting the sass variables from bootstrap's _variables.scss file into your own projects sass file somewhere, like:
Now your gutters will be 50px instead of 30px. I find this to be the cleanest method to adjust the gutter size.
You can keep the default behaviour (with gutter) and add a class to your CSS stylesheet for tasks like yours:
And here’s how you can use it in your HTML:
I don't think Bass's answer is correct. Why touch the row margins? They have a negative margin to offset the column padding for the columns on the edge of the row. Messing with this will break any nested rows.
The answer is simple, just make the container padding equal to the gutter size:
e.g for default bootstrap:
http://jsfiddle.net/3wBE3/61/