I have a Bootstrap 4 card that I am working with. Currently, when I hover over any part of the card, a transparent overlay covers the entire card. I would like to modify this effect so that the overlay only appears over the top image area of the card, not the entire card.
HTML:
<div class="m-4">
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="https://via.placeholder.com/150x100" alt="Card image cap">
<div class="card-overlay"></div>
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text.</p>
</div>
</div>
</div>
CSS
.card-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background: rgba(0, 0, 0, 0.5);
}
.card:hover .card-overlay {
opacity: 1;
}