freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #2 of 50

3d transforms · perspective · rotate3d

PrismaVSJank the Janitor
Prisma says3D transforms add depth with perspective, rotateX/Y/Z, and translateZ.

Add a perspective and you can rotate elements in 3D: rotateY(180deg) flips a card, translateZ moves toward/away. transform-style: preserve-3d keeps children in the same 3D space — the basis of flip cards and 3D scenes.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleBuild a flip card: rotateY(180deg) on hover with preserve-3d and hidden backfaces.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.scene{perspective:600px}.card{width:140px;height:90px;transition:transform .5s;transform-style:preserve-3d;position:relative}.scene:hover .card{transform:rotateY(180deg)}.face{position:absolute;inset:0;backface-visibility:hidden;display:grid;place-items:center;color:#06040d}.front{background:#b388ff}.back{background:#8aff9d;transform:rotateY(180deg)}</style></head><body style="background:#06040d;padding:30px"><div class="scene"><div class="card"><div class="face front">front</div><div class="face back">back</div></div></div></body></html>
▶ Open the interactive comic issue
‹ Transforms · Translate · Rotate · Scale · SkewTransitions · Property · Duration · Timing · Delay ›