Bootstrap

How to Remove Gutter Space for a Specific div in Bootstrap

The Bootstrap grid system consists of many containers, rows, and columns for layout and content alignment. The grid system set out a row having 12 virtual columns to make web pages fully responsive. However, there is padding or spaces around or between the columns. These spaces are known as “gutter spaces”.

This post will discuss what gutter spaces are and how they can be removed for a specific div in Bootstrap.

What is Gutter Space in Bootstrap?

The gutters are the spaces or gaps between the columns produced by horizontal padding. They are used to support responsive content alignment and spaces in the Bootstrap grid system.

Below given image shows a row with a red border around it. Within the row, three equal-sized div elements of equal grid columns exist. Although the columns are equal, there are still gutter spaces between them:

How to Remove Gutter Space for a Specific div in Bootstrap?

In Bootstrap, the class “no-gutters” is utilized to eliminate the gutter spaces of any div.

For this purpose:

  • Add a “<div>” tag along with the class “main-div”.
  • Then, adjust a row section by adding another “<div>” element with the class “row”. As we have to remove the spaces from the row, specify a class “no-gutters” within it.
  • To divide the grid row into three equal columns, utilize the class “col-4”.
  • Within each column’s “<div>” container, adjust the “<div>” elements with classes “column-1”, “column-2”, and “column-3”, respectively:
<div class="main-div">

<div class="row no-gutters">

<div class="col-4 ">

<div class="column-1"></div>

</div>

<div class="col-4">

<div class="column-2"></div>

</div>

<div class="col-4">

<div class="column-3"></div>

</div>

</div>

</div>

CSS

In the CSS section, the classes mentioned in the HTML page are styled with several styling properties.

Style “main-div” class

.main-div {

width: 600px;

margin: 50px auto;

}

The “.main-div” is mentioned to access the div element having class “main-div”. The following properties are applied to this class:

  • width” defines the element’s width.
  • margin” sets the spacing around the element.

Style “row” class

.row {

border: 1px solid red;

}

The Bootstrap “row” class is added with the “border” property. This will wrap the grid row in a specified width, style, and color border.

The three classes “column-1”, “column-2”, and “column-3” are assigned the CSS “background-color” and “height” properties to make them prominent.

Style “column-1” class

.column-1 {

background-color: turquoise;

height: 200px;

}

Style “column-2” class

.column-2 {

background-color: violet;

height: 200px;

}

Style “column-3” class

.column-3 {

background-color: yellowgreen;

height: 200px;

}

It can be observed that the “<div>” container with the class “row” has been successfully adjusted with no gutter space between them:

We have taught you how to remove gutter space for a specific div in Bootstrap.

Conclusion

To remove gutter spaces for a specific div, the class “no-gutters” can be used. For this purpose, add the “<div>” element along with the “row no-gutters” class. This post has provided a comprehensive guide on gutter spaces and how they can be eliminated for a specific div in Bootstrap.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.