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.
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.
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.
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.
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 .
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.
.row
classwith:
.row { margin-left: 0; margin-right: 0; }
.container
classwith:
.container { padding-left:30px; padding-right:30px; }
Notice sub grids shouldn't wrapped inside a .container
class.
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>
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