StealThis .dev

3D Tilt Card with Glare

Pointer-driven 3D tilt cards that rotate toward the cursor with a moving specular glare, layered parallax depth, and a smooth spring-back on leave — pure CSS transforms and vanilla JS.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

A grid of interactive product cards that respond to pointer movement with realistic 3D perspective. As the cursor moves across a card, JavaScript maps its position to rotateX/rotateY values and writes them to CSS custom properties, so the card visually leans toward the pointer. A radial glare highlight tracks the same coordinates to simulate light glancing off a glossy surface, while inner layers (badge, artwork, title) are pushed forward along the Z axis with translateZ to create genuine parallax depth.

The interaction is built on the Pointer Events API, so a single set of handlers covers mouse, trackpad, touch and pen input. On pointer leave the card animates back to its resting state with a spring-like transition, and the glare fades out. A live readout shows the current rotation angles, and a control lets you tune the maximum tilt intensity in real time. Everything is keyboard-focusable with a visible focus ring, and prefers-reduced-motion is honored by disabling the tilt for users who opt out.

Under the hood the demo leans entirely on the web platform: CSS perspective and transform-style: preserve-3d for the 3D scene, custom properties as the bridge between JS and CSS, and requestAnimationFrame to keep pointer updates smooth and jank-free.