Looking to create a block with an overlay hover effect - defaulting to a weak black background color and changing to no black background on hover. I want to include an icon and text in the center that remain unaffected by the hover state.
How can I prevent the icon and text from being affected by the hover effect?
I've experimented with various rules for both the overlay div and the icon div, but haven't had any success.
Is there a CSS rule that allows for some kind of exclusion?
I did manage to make it work by placing them outside the divs with the overlay background, but then the hover effect breaks when hovering over the icon and text.
You can view the code here.
<style>
.media-front-top-picture{
background-image: url("");
height:500px;
}
.media-front-top-icon{
content: url("");
width: 130px;
margin: auto;
padding-top: 200px;
opacity: 1;
}
.media-front-txt{
font-size: 22px;
letter-spacing: 8px;
color: white;
margin-top: 15px;
}
.media-front-bottom-picture{
background-image: url("");
height:500px;
}
.media-front-bottom-icon{
content: url("");
width:130px;
margin: auto;
padding-top: 200px;
}
.media-picture-container {
position: relative;
}
.media-picture-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.47);
}
.media-picture-overlay:hover {
opacity: 0;
cursor:pointer;
}
</style>
<div class="body-media">
<div class="media-picture-container">
<div class="media-front-top-picture" style="border-bottom:4px solid white;">
<div class="media-front-top-icon"></div>
<div class="media-front-txt">VIDEOS</div>
<div class="media-picture-overlay"></div>
</div>
</div>
<div class="media-picture-container">
<div class="media-front-bottom-picture" style="border-bottom:4px solid white;">
<div class="media-front-bottom-icon"></div>
<div class="media-front-txt">PICTURES</div>
<div class="media-picture-overlay"></div>
</div>
</div>
</div>