Hover or focus the image to see the effect.
HTML
CSS
.hover-effect.gradient-overlay{
position: relative;
display: block;
}
.hover-effect.gradient-overlay::before{
content: "";
position: absolute;
inset: 0;
background: linear-gradient(
to bottom,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.7) 100%
);
opacity: 0;
transition: opacity 0.4s ease;
pointer-events: none;
}
.hover-effect.gradient-overlay:hover::before,
.hover-effect.gradient-overlay:focus-visible::before{
opacity: 1;
}
The ::before fades in a top-to-bottom black gradient on hover/focus. Select the code and copy with Ctrl+C or ⌘C.