Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 Gutter Size

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:

enter image description here

by default, they look like this, the vertical gutters in between columns (marked with blue) are double the horizontal and outside gutters:

enter image description here

Any help on the best way to solve this probably would be appreciated.

like image 504
Billy Avatar asked Sep 27 '13 02:09

Billy


People also ask

How wide are Bootstrap gutters?

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.

What is gutter width?

If there's a standard gutter size, it would be 5 inches for seamless gutters. That's what many residential homes have, though you can also opt for other common choices. Those can include 4-inch or 6-inch gutters or, in special cases, 7-inch gutters.

What is gutter size in CSS?

Gutters or alleys are spacing between content tracks. These can be created in CSS Grid Layout using the column-gap , row-gap , or gap properties.

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 .


2 Answers

try:

.row {     margin-left: 0;     margin-right: 0; } 

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:

<div class="container" style="background-color:darkblue;">   <div class="row" style="background-color:yellow;">   <div class="col-md-9" style="background-color:green;">     <div style="background-color:lightblue;">div 1: .col-md-9</div>     <div class="row" style="background-color:orange;">       <div class="col-md-6" style="background-color:red;">         <div style="background-color:lightblue;">div 2: .col-md-6</div>       </div>       <div class="col-md-6" style="background-color:red;">         <div style="background-color:lightblue;">div 2: .col-md-6</div>       </div>     </div>   </div>     <div class="col-md-3" style="background-color:green;">     <div style="background-color:lightblue;">div 1: .col-md-3</div>   </div>       </div> </div> 

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:

enter image description here

margin of the .row class

with:

.row {     margin-left: 0;     margin-right: 0; } 

enter image description here

padding of the .container class

with:

.container {     padding-left:30px;     padding-right:30px; } 

enter image description here

Notice sub grids shouldn't wrapped inside a .container class.

like image 185
Bass Jobsen Avatar answered Sep 21 '22 14:09

Bass Jobsen


You can keep the default behaviour (with gutter) and add a class to your CSS stylesheet for tasks like yours:

.no-gutter > [class*='col-'] {     padding-right:0;     padding-left:0; } 

And here’s how you can use it in your HTML:

<div class="row no-gutter">     <div class="col-md-4">         ...     </div>     <div class="col-md-4">         ...     </div>     <div class="col-md-4">         ...     </div> </div> 
like image 33
Zod Avatar answered Sep 19 '22 14:09

Zod