Perspective Shift

Image shifts off-axis in 3D space on hover/focus via translateZ plus a horizontal translate.

Perspective Shift demo

Hover or focus the image to see the effect.

HTML

description

CSS

.hover-effect.perspective-shift img{
  transition: transform 0.5s ease;
}
.hover-effect.perspective-shift:hover img,
.hover-effect.perspective-shift:focus-visible img{
  transform: perspective(800px) translateZ(40px) translateX(-25px) scale(1.1);
}
@media (prefers-reduced-motion: reduce) {
  .hover-effect.perspective-shift img{
    transition: none;
  }
  .hover-effect.perspective-shift:hover img,
  .hover-effect.perspective-shift:focus-visible img{
    transform: perspective(800px) translateZ(40px) translateX(-25px) scale(1.1);
  }
}

The animates transform: perspective(800px) translateZ(40px) translateX(-25px) scale(1.1) for an off-axis perspective shift. Select the code and copy with Ctrl+C or ⌘C.