Hover or focus the image to see the effect.
HTML
<div class="hover-effect pan-top-right">
<img src="image.jpg" alt="description">
</div>
CSS
.hover-effect.pan-top-right{
overflow: hidden;
}
.hover-effect.pan-top-right img{
transform: scale(1.2);
transition: transform 0.5s ease;
}
.hover-effect.pan-top-right:hover img,
.hover-effect.pan-top-right:focus-visible img{
transform: scale(1.2) translate(25px, -25px);
}
@media (prefers-reduced-motion: reduce) {
.hover-effect.pan-top-right img{
transition: none;
}
.hover-effect.pan-top-right:hover img,
.hover-effect.pan-top-right:focus-visible img{
transform: scale(1.2);
}
}
Select the code and copy with Ctrl+C or ⌘C.