3D Tilt

Image tilts on both X and Y axes on hover/focus for a 3D card-style tilt.

3D Tilt demo

Hover or focus the image to see the effect.

HTML

description

CSS

.hover-effect.tilt-3d img{
  transition: transform 0.5s ease;
}
.hover-effect.tilt-3d:hover img,
.hover-effect.tilt-3d:focus-visible img{
  transform: perspective(800px) rotateX(15deg) rotateY(15deg) scale(1.25);
}
@media (prefers-reduced-motion: reduce) {
  .hover-effect.tilt-3d img{
    transition: none;
  }
  .hover-effect.tilt-3d:hover img,
  .hover-effect.tilt-3d:focus-visible img{
    transform: perspective(800px) rotateX(15deg) rotateY(15deg) scale(1.25);
  }
}

The animates transform: perspective(800px) rotateX(15deg) rotateY(15deg) scale(1.25) for a 3D card-style tilt. Select the code and copy with Ctrl+C or ⌘C.