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