Hover or focus the image to see the effect.
HTML
<div class="hover-effect fade-to-color">
<img src="image.jpg" alt="description">
</div>
CSS
.hover-effect.fade-to-color{
position: relative;
}
.hover-effect.fade-to-color::before{
content: "";
position: absolute;
inset: 0;
background: rgba(70, 130, 180, 0.95);
transition: opacity 0.45s ease;
}
.hover-effect.fade-to-color:hover::before,
.hover-effect.fade-to-color:focus-visible::before{
opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
.hover-effect.fade-to-color::before{
transition: none;
}
.hover-effect.fade-to-color:hover::before,
.hover-effect.fade-to-color:focus-visible::before{
opacity: 0;
}
}
Select the code and copy with Ctrl+C or ⌘C.