Hover or focus the image to see the effect.
HTML
CSS
.hover-effect.solid-overlay{
position: relative;
display: block;
}
.hover-effect.solid-overlay::before{
content: "";
position: absolute;
inset: 0;
background: rgba(0, 0, 0, 0.5);
opacity: 0;
transition: opacity 0.4s ease;
pointer-events: none;
}
.hover-effect.solid-overlay:hover::before,
.hover-effect.solid-overlay:focus-visible::before{
opacity: 1;
}
The ::before pseudo-element fades from 0 to 1 opacity on hover/focus, covering the image with a solid 50% black layer. Select the code and copy with Ctrl+C or ⌘C.