I have an image that should be full width at the top of a screen. I've removed padding left and right using px-0 but this has affected the page. I am now able to move around the page with the cursor. I do not want that to be the case
<div class="container-fluid px-0">
<div class="row d-none d-md-block">
<div class="col-12">
<img src="~/images/banners/group_full.png" alt="Image of a group of people" class="img-fluid" />
</div>
</div>
</div>
Besides adding Bootstrap class px-0
to the container-fluid
, you also need to add mx-0
to the row
and px-0
to the col-12
.
Generally speaking, Bootstrap adds margins and paddings to all elements. In case you have a similar problem in the future, always check margins and paddings of all elements (container-fluid
, row
, col
, etc.).
See the snippet below.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<div class="container-fluid px-0">
<div class="row d-none d-md-block mx-0">
<div class="col-12 px-0">
<img src="~/images/banners/group_full.png" alt="Image of a group of people" class="img-fluid" />
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
</body>
</html>