'bootstrap 4 container-fluid is not full width after removing the default padding
I want to make a full width web page by Bootstrap 4.
I try to remove the original 15px padding of container-fluid, but it is still not working.
Details on jsfiddle. I marked the whole background as purple but u can see the jumbotron is not fully cover on the purple background.
<style>
.container-fluid {
padding: 0 !important;
}
</style>
Solution 1:[1]
Just use the p-0 and m-0 utility classes on the col and jumbotron (no extra CSS needed)...
<div class="container-fluid">
<div class="row">
<div class="col-md-12 p-0" style="background: purple;">
<div class="jumbotron m-0">
<h2>
Hello, world!
</h2>
<p>
This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.
</p>
<p>
<a class="btn btn-primary btn-large" href="#">Learn more</a>
</p>
</div>
</div>
</div>
</div>
Solution 2:[2]
<div class="container-fluid px-0">
<div class="row">
<div class="col-12">
your-content-goes-here
</div>
</div>
</div>
https://getbootstrap.com/docs/4.1/utilities/spacing/#examples
Solution 3:[3]
Adding the class container-full-width worked for me.
<div class="container-full-width">
<div class=" row ">
<div class="col-12">
Solution 4:[4]
We can use the following to get rid of the purple space
.container-fluid {
padding-left: 0;
padding-right: 0;
}
.jumbotron {
margin: 0;
}
However, https://stackoverflow.com/a/50389225/4513747 provides a more elegant solution using the existing classes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zim |
| Solution 2 | Carousel |
| Solution 3 | isherwood |
| Solution 4 | Ishan Madhusanka |
