I'm currently working on setting up a grid of thumbnails for my blog posts using Bootstrap 4.
The columns have a size of col-md-6
. Within each column, there is an anchor with a background image and a gradient overlay that transitions from black to transparent.
Everything seems to be functioning correctly, but the issue arises when the gradient overlay extends beyond the width of the container, as shown in the image below.
https://i.sstatic.net/IZghE.png Code Snippet:
<div class="container homeSection">
<div class="row">
<div class="col-md-6 dualBlogCallout">
<a href="#">
<div class="img-holder border-radius-15">
<div class="dualGradient"></div>
<img src="assets/img/beachPlaceholder.png" class="img-fluid w-100" alt="Blog Alt"/>
</div>
</a>
</div>
<div class="col-md-6 dualBlogCallout">
<a href="#">
<div class="img-holder border-radius-15">
<div class="dualGradient"></div>
<img src="assets/img/beachPlaceholder.png" class="img-fluid w-100" alt="Blog Alt"/>
</div>
</a>
</div>
</div>
</div>
CSS Styles:
.dualBlogCallout{
color: white;
position: relative;
width: 100%;
bottom: 0;
left: 0;
z-index: 5;
}
.dualBlogCallout a{
overflow: hidden;
}
.dualGradient{
background-image: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,1));
position: absolute;
left: 0;
bottom: 0;
opacity: 1;
width: 100%;
height: 300px;
pointer-events: none;
z-index: 1;
}
Desired Outcome:
https://i.sstatic.net/Af1ef.jpg
I'm looking for guidance on how to contain the absolutely positioned gradient within the anchor element without any overflow issues, while avoiding the use of the Bootstrap 4 no-gutter
class. Can anyone help me achieve this?