I am currently working on a website using Bootstrap 4. One of the features I have implemented is a set of thumbnail images with text overlays that change color when hovered over. However, the hover effect disappears when hovering over the text. Any suggestions on how to maintain the effect even when the text overlay is hovered over?
Below is the HTML code:
<div class="row learn_more">
<div class="col-md-3 col-6 learn_more-item">
<a href="/work/index.html" class="learn_more-link">
<div class="learn_more-hover">
</div>
<img src="img/work.png" class="img-fluid" alt="work">
<div class="learn_more-text">
<p>Work</p>
</div>
</a>
</div>
<div class="col-md-3 col-6 learn_more-item">
<a href="/about/index.html" class="learn_more-link">
<div class="learn_more-hover">
</div>
<img src="img/about.png" class="img-fluid" alt="about">
<div class="learn_more-text">
<p>About</p>
</div>
</a>
</div>
</div>
This is the CSS for the design:
.learn_more-link {
display: block;
position: relative;
}
.learn_more-hover {
background: rgba(221, 33, 99, 0.75);
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
}
.learn_more-hover:hover {
opacity: 1;
}
.learn_more * {
z-index: 2;
}
.learn_more img {
opacity: 0.25;
}
.learn_more-text {
text-align: left;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 2rem;
font-weight: bold;
}
UPDATE:
After taking your advice into consideration, I made some changes to the code.
Here is the updated HTML:
<div class="row learn_more">>
<div class="col-md-3 col-6 learn_more-item"/>
<a href="/work/index.html" class="learn_more-link"/>
<img src="img/work.png" class="img-fluid" alt="work"/><span class="learn_more-text">Work</span>
</a>
</div>
<div class="col-md-3 col-6 learn_more-item"/>
<a href="/about/index.html" class="learn_more-link"/>
<img src="img/about.png" class="img-fluid" alt="about"/><span class="learn_more-text">About</span>
</a>
</div>
</div>
And here is the updated CSS:
.learn_more-link {
display: block;
position: relative;
}
.learn_more-link:hover {
background: rgba(221, 33, 99, 0.75);
}
.learn_more img {
opacity: 0.25;
}
.learn_more-text {
text-align: left;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 2rem;
font-weight: bold;
}