Use px-0
on the container
and no-gutters
on the row
to remove the paddings.
Quoting from Bootstrap 4 - Grid system:
Rows are wrappers for columns. Each column has horizontal padding (called a gutter) for controlling the space between them. This padding is then counteracted on the rows with negative margins. This way, all the content in your columns is visually aligned down the left side.
Columns have horizontal padding to create the gutters between individual columns, however, you can remove the margin from rows and padding from columns with
.no-gutters
on the.row
.
Following is a live demo:
h1 {
background-color: tomato;
}
_x000D_
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
<div class="container-fluid" id="div1">
<div class="row">
<div class="col">
<h1>With padding : (</h1>
</div>
</div>
</div>
<div class="container-fluid px-0" id="div1">
<div class="row no-gutters">
<div class="col">
<h1>No padding : > </h1>
</div>
</div>
</div>
_x000D_
The reason this works is that container-fluid
and col
both have following padding:
padding-right: 15px;
padding-left: 15px;
px-0
can remove the horizontal padding from container-fluid
and no-gutters
can remove the padding from col
.