Compress

Image starts slightly zoomed in (covering the viewport) and compresses back to its natural size on hover/focus.

Compress demo

Hover or focus the image to see the effect.

HTML

description

CSS

.hover-effect.compress img{
  transform: scale(1.4);
  transition: transform 0.5s ease;
}
.hover-effect.compress:hover img,
.hover-effect.compress:focus-visible img{
  transform: scale(1);
}
@media (prefers-reduced-motion: reduce) {
  .hover-effect.compress img{
    transition: none;
  }
  .hover-effect.compress:hover img,
  .hover-effect.compress:focus-visible img{
    transform: scale(1);
  }
}

The starts at transform: scale(1.4) (covering the viewport) and compresses to scale(1) on hover/focus. Select the code and copy with Ctrl+C or ⌘C.