Hover or focus the image to see the effect.
HTML
<div class="hover-effect slide-cover-right">
<img src="image.jpg" alt="description">
</div>
CSS
.hover-effect.slide-cover-right{
position: relative;
}
.hover-effect.slide-cover-right::before{
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
background: #1a1a1a;
transition: width 0.5s ease;
}
.hover-effect.slide-cover-right:hover::before,
.hover-effect.slide-cover-right:focus-visible::before{
width: 100%;
}
@media (prefers-reduced-motion: reduce) {
.hover-effect.slide-cover-right::before{
transition: none;
}
.hover-effect.slide-cover-right:hover::before,
.hover-effect.slide-cover-right:focus-visible::before{
width: 100%;
}
}
The cover pseudo is anchored to the right edge and its width grows from zero to full on hover. Select the code and copy with Ctrl+C or ⌘C.