I've been struggling to find a solution to stretch an image across a div using CSS and Bootstrap. I attempted to make both the div and parent container fluid, but no matter what I try, there always seems to be some white space on the left and right sides of the image.
Here is the HTML code:
<div class="container-fluid">
<div class="row color-block-top"></div>
<div class="row-fluid block">
<img src="Images/family-beach.jpg" alt="Family on the beach" class="beach">
</div>
<div class="row color-block-top"></div>
</div>
And the corresponding CSS:
.color-block-top {
background-color: rgb(36,54,138);
padding: 1vh;
min-width: 20em;
}
.block {
display: block;
margin-left: auto;
margin-right: auto;
object-fit: fill;
width: 100%;
}
.beach {
margin: 0;
min-width: 100%;
height: 500px;
object-fit: cover;
overflow: hidden;
}