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?
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 .
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.
The Bootstrap grid allows 12 columns with 30 px wide gutters by default, but these numbers can be adjusted.
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; }
For Bootstrap 4 see: Remove gutter space for a specific div only
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With