Hover or focus the image to see the effect.
HTML
CSS
.hover-effect.contrast-to-normal img{
filter: contrast(0.5);
transition: filter 0.5s ease;
}
.hover-effect.contrast-to-normal:hover img,
.hover-effect.contrast-to-normal:focus-visible img{
filter: contrast(1);
}
@media (prefers-reduced-motion: reduce) {
.hover-effect.contrast-to-normal img{
transition: none;
}
.hover-effect.contrast-to-normal:hover img,
.hover-effect.contrast-to-normal:focus-visible img{
filter: contrast(1);
}
}
The animates filter: contrast() from 0.5 to 1 (inverse of contrast-decrease). Select the code and copy with Ctrl+C or ⌘C.