Rotate X

Image rotates around the X axis on hover/focus for a 3D tilt effect.

Rotate X demo

Hover or focus the image to see the effect.

HTML

description

CSS

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

The animates transform: perspective(800px) rotateX(25deg) scale(1.25) for a 3D X-axis rotation. Select the code and copy with Ctrl+C or ⌘C.