I need assistance with adding an overlay to only the bootstrap 4 figure-img. In order to achieve this, I inserted a div with the class overlay beneath the figure-img.
Below is the code snippet:
<div class="col-md-4">
<figure class="service text-center">
<img src="img/service1.jpg" class="figure-img img-fluid w-100" alt="Repair Request Service">
<div class="overlay"></div>
<figcaption class="figure-caption">
<h4>Repair Request Service</h4>
<p>We care about you and your vehicle. Whether it's for an auto repair or scheduled maintenance, we ensure that you are well taken care of.</p>
<a class="btn btn-primary" href="#">Read More</a>
</figcaption>
</figure>
</div>
The CSS looks like this:
.services .figure-img {
margin-bottom: 0;
position: relative;
}
.overlay {
position: absolute;
top: 0;
background: #f00;
height: 100%;
width: 100%;
opacity: 0;
display: none;
}
.service:hover .overlay {
display:block;
opacity: .3;
}
However, the overlay is currently taking up the full width, including the padding on the right and left sides of col-md-4, resulting in this display:
https://i.sstatic.net/1BaJi.jpg
How can I resolve this issue and properly position the overlay within the .figure-img element?