Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust gutter in Bootstrap 3 grid system?

The new Bootstrap 3 grid system is great. It's more powerful for responsive design at all screen sizes, and much easier for nested.

But I have one issue I could not figure out. How do I add precise gap between the columns? Say I have container 960px, 3 columns at 310px and 2 gutters at 15px in between 3 columns. How do I do that?

like image 541
Darren Li Avatar asked Nov 11 '13 16:11

Darren Li


People also ask

How do I reduce the gutter space in Bootstrap?

Use the `no-gutters` to remove the spacing (gutter) between columns. Bootstrap uses padding to create the spacing (A.K.A “gutter”) between columns. If you want columns with no horizontal spacing, Bootstrap 4 includes a no-gutters class that can be applied to the entire row .

What is gutter margin in Bootstrap?

Gutters are the gaps between column content, created by horizontal padding . We set padding-right and padding-left on each column, and use negative margin to offset that at the start and end of each row to align content. Gutters start at 1.5rem ( 24px ) wide.

How wide are Bootstrap gutter by default?

The Bootstrap grid allows 12 columns with 30 px wide gutters by default, but these numbers can be adjusted.


1 Answers

You could create a CSS class for this and apply it to your columns. Since the gutter (spacing between columns) is controlled by padding in Bootstrap 3, adjust the padding accordingly:

.col {   padding-right:7px;   padding-left:7px; } 

Demo: http://bootply.com/93473

EDIT If you only want the spacing between columns you can select all cols except first and last like this..

.col:not(:first-child,:last-child) {   padding-right:7px;   padding-left:7px; } 

Updated Bootply

For Bootstrap 4 see: Remove gutter space for a specific div only

like image 124
Zim Avatar answered Oct 11 '22 14:10

Zim