CSS 3D perspective generator — tilt cards in real depth

Set how far the viewer is from the scene, then tilt and push a sample card in three dimensions; the tool writes the perspective for the parent and the 3D transform for the card.

Live demo · real result from this tool

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the CSS 3D perspective generator

  1. Set the Perspective distance from 100 to 2,000 px. Lower is more dramatic.
  2. Tilt the card with rotateX (top and bottom edges), rotateY (left and right edges) and spin it flat with rotateZ.
  3. Use translateZ to bring the card forward or push it back.
  4. Move the vanishing point with perspective-origin if the viewer should look from above, below or the side.
  5. Copy both rules: .scene goes on the parent, .card on the element you tilt.

What it does and when to use it

CSS 3D transforms make flat elements look like objects in space. Typical uses are product cards that tilt slightly on hover, cover-flow style galleries, flip cards with a question on the front and the answer on the back, and isometric-looking feature panels.

For flat moves, turns and scaling, the CSS transform generator is simpler. To animate the tilt on hover, add the CSS transition generator, and to give the card depth with a shadow, the box shadow generator.

How it works

The .scene rule gets perspective: <distance>px, plus perspective-origin when you choose something other than centre. The .card rule gets the transform functions you changed, always in the order translateZ, rotateX, rotateY, rotateZ, followed by transform-style: preserve-3d. Any function left at 0 is dropped; if all are 0 the transform is none.

MDN lists perspective, perspective-origin and transform-style as Baseline widely available since September 2015.

Worked examples

The default tilt, perspective 800 px:

.scene {
  perspective: 800px;
}
.card {
  transform: rotateX(20deg) rotateY(-30deg);
  transform-style: preserve-3d;
}

The card leans back and turns its left edge away from you.

A door half open. Perspective 300 px, rotateY 60°, nothing else: transform: rotateY(60deg);. With the short distance, the near edge looks much taller than the far one.

A card lifted towards the viewer from above. Perspective 1,200 px, translateZ 100 px, perspective-origin top: the scene gets perspective-origin: top; and the card transform: translateZ(100px);. It appears larger and as if seen from slightly above.

Limits and tips

  • The back of a rotated card is visible past 90°, mirrored. For flip cards, add backface-visibility: hidden to each face by hand.
  • Text on steep angles is hard to read. Keep tilts small on anything people need to read.
  • 3D motion can cause discomfort. If you animate it, honour prefers-reduced-motion and keep movements short.

Frequently asked questions

Why is perspective on the parent and not on the card?
The perspective property sets up a viewpoint for an element's children. Putting it on .scene means every card inside shares one vanishing point, like objects in the same room. You can also write perspective() inside a single element's transform, but then each element gets its own viewpoint.
What does a smaller perspective distance do?
It moves the viewer closer, so the 3D effect becomes stronger and more distorted. Around 800px looks natural for a card; 200–300px looks dramatic, like a wide-angle lens.
Why does the card look flat even though I rotated it?
Without perspective on a parent, rotateX and rotateY only squash the element. Make sure the .scene rule is on the card's direct parent.
What is transform-style preserve-3d for?
It lets the card's own children keep their 3D positions instead of being flattened onto the card. It matters for things like a flip card with a front and back face; for a single flat card it changes nothing.
Why does translateZ make the card bigger?
Positive translateZ moves the card towards the viewer, so with perspective it appears larger. Negative values push it away and it shrinks.

Sources

  1. perspective - CSS | MDN — MDN Web Docs, accessed 2026-10-08
  2. transform-style - CSS | MDN — MDN Web Docs, accessed 2026-10-08

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close