CSS perspective 3D card: how transform order changes the result

PublishedToolCSS 3D Transform Generator

Contents
  1. Why your CSS 3D card keeps looking flat
  2. The order in which perspective, rotate, translateZ, and scale combine
  3. The parts people get tripped up on
  4. Wrap-up
  5. Frequently Asked Questions

To spin a card or a box in 3D with CSS alone, you first need to know how six values — perspective, rotateX, rotateY, rotateZ, translateZ, and scale — combine, in what order, and what each one actually changes.

These six values aren't something you eyeball. They follow fixed rules, so once you know the rules, you can predict the result exactly.

I put this together so front-end developers and UI developers building hover cards or 3D cube effects can change one value at a time and check the rules for themselves.

Summary ① perspective belongs on the parent, not on the element you're rotating — that's what creates the depth distortion. ② Transform functions are calculated left to right, so the same values in a different order give a different result. ③ translateZ looks bigger or smaller depending on the perspective value, while scale multiplies the on-screen size regardless of perspective.

Why your CSS 3D card keeps looking flat

You paste in a CSS 3D card example you found online, and instead of rotating in 3D, the card just looks like a rectangle squashed at an angle. You clearly set rotateY(30deg), but all you get is a tilted flat plane with no sense of depth.

The cause is almost always one of two things. Either you never declared perspective at all, or you put perspective on the element you're rotating.

perspective defines the virtual distance between the viewer and the z=0 plane. But it applies to the children of the element that has the property, not to the element itself. So putting it on the element you want to rotate does nothing.

The other cause is the order of the transform functions. rotateY(30deg) translateZ(50px) and translateZ(50px) rotateY(30deg) use the same numbers but produce different results. That's because CSS applies the functions in a transform list from left to right.

The order in which perspective, rotate, translateZ, and scale combine

Follow these steps in order and you can build the same result in plain CSS, no tool needed.

  1. Declare perspective on the parent element. Put perspective: 600px; on the container that wraps the card you want to rotate. This value is the virtual distance from the viewer to the z=0 plane. It has to go on the parent that holds the card, not on the card itself, or the card won't show any depth distortion when it turns.
  2. The size of the perspective value sets how strong the distortion is. A smaller value (say 200–400px) puts the viewer right up against the card, so the front and back faces differ a lot in size when it rotates and the distortion is strong. A larger value (say 1500–2000px) moves the viewer back, so the distortion eases off and the rotation looks closer to a flat one.
  3. rotateX, rotateY, and rotateZ spin around different axes. rotateX turns around the horizontal axis, so the top and bottom of the card tilt forward and back. rotateY turns around the vertical axis, so the left and right sides tilt forward and back. rotateZ turns around the axis pointing straight at you, which looks the same as a 2D rotation.
  4. translateZ pulls the card toward the viewer or pushes it away. A positive value brings the card closer to the viewer (toward the front of the screen), and a negative value moves it farther away (behind the screen). Once perspective is in play, this movement alone makes the card look bigger or smaller, because of perspective projection: closer looks bigger, farther looks smaller.
  5. scale multiplies the on-screen size only, independent of perspective. translateZ changes how big the card looks by moving it through distance. scale multiplies the element's rendered size by the factor you give it, with no z-axis movement at all. translateZ(100px) and scale(1.5) can both make a card look bigger, but they differ in whether they respond to perspective distortion.
  6. String the final transform together in order. Write it like transform: rotateX(25deg) rotateY(-30deg) rotateZ(0deg) translateZ(0px) scale(1);. Each function is calculated left to right, and that determines the final shape. Add transform-style: preserve-3d; and transition: transform 0.1s ease; on top, and you get a card that animates smoothly when the values change.

You can also verify these rules by hand — change one of the six values, save, refresh the browser, and repeat. The catch is that you have to edit, save, and reload every single time, so comparing several combinations by eye takes a while.

Check it with our free tool.

CSS 3D Transform Generator

As you move the sliders, the CSS updates in real time. All calculations run in your browser, so nothing is sent to a server.

The parts people get tripped up on

The values themselves aren't hard, but these four spots are where the result usually doesn't match expectations.

MistakeWhat you seeWhy it happens
Putting perspective on the element you're rotatingIt rotates, but it looks flat with no depth distortionperspective applies to the children of the element that has it, so it does nothing on the element itself
Leaving perspective out entirelyrotateX/rotateY just looks like a tilted flat planeWithout perspective projection, rotation doesn't change the relative size of the front and back faces
Changing the order of the transform functionsThe same numbers give a different shape than the exampleTransform functions apply left to right, so the order is the calculation order
Forgetting preserve-3d on nested 3D elements like a cubeThe faces don't look 3D and collapse into each otherThe default flat value flattens the child's 3D transform onto the parent's plane

transform-style: preserve-3d is needed for the same reason. At the default flat value, the 3D transforms on child elements get flattened onto the plane the parent sits on before rendering.

To combine several faces into something that looks like a cube, set preserve-3d on the element that wraps those faces, so the children's 3D positions aren't flattened and stay as they are.

Wrap-up

  • perspective goes on the parent, not on the element you're rotating, and smaller values mean stronger depth distortion.
  • rotateX, rotateY, and rotateZ spin around different axes, and transform functions are calculated left to right.
  • translateZ makes the card look bigger or smaller in response to perspective, while scale multiplies only the on-screen size regardless of perspective.
  • Nested 3D elements (like a cube) need transform-style: preserve-3d to stay 3D instead of being flattened.
  • Drag the sliders and you can watch each of these rules show up live in the CSS text.
CSS 3D Transform Generator

As you move the sliders, the CSS updates in real time. All calculations run in your browser, so nothing is sent to a server.

Frequently Asked Questions

What perspective value should I use?

There's no single right answer. For a given rotation angle, the only fixed relationship is that a smaller perspective (200–400px) exaggerates the distortion and a larger one (1000px and up) makes it subtler. How much distortion you want depends on the situation, so try comparing a few values with the sliders and pick the one you like.

Does the order of rotateX and rotateY change the result?

Yes, it does. Transform functions are evaluated from left to right, so rotateX(25deg) rotateY(-30deg) and rotateY(-30deg) rotateX(25deg) produce different results. Because the two rotations spin around different axes, swapping the order changes the final orientation.

Changing only translateZ makes the card look bigger: how is that different from scale?

translateZ physically moves the card toward the viewer, and how much bigger it looks depends on the perspective value. scale doesn't move anything; it just multiplies the rendered size by a factor, so it always grows or shrinks at the same ratio regardless of the perspective value.

What's the difference between the 3D Card tab and the 3D Cube tab?

The 3D Card tab applies perspective plus rotation, translation, and scale values to a single gradient card, showing how one flat plane tilts into three dimensions. The 3D Cube tab places six faces — front, back, left, right, top, and bottom — using translateZ(50px) with rotateY/rotateX to build a cube, and the same slider values are applied to all six faces so they rotate together.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. CSS Specificity Calculator: Check Selector Priority (A-B-C)See how a CSS selector's specificity is scored as A-B-C, how :not(), :is(), and :where() count, and why a later rule sometimes loses.
  2. CSS Text Truncation: Single-Line Ellipsis and Multi-Line ClampUse three CSS properties to cut text to one line, -webkit-line-clamp for 2–5 lines, and fix the Flexbox bug where the ellipsis breaks the parent.
  3. Remove duplicate lines online and sort a list without ExcelSee how duplicate line removal works: line breaks split the list, and case and whitespace options decide what counts as a duplicate. Includes sort order.
  4. Drop Cap CSS: Style the First Letter with ::first-letterLearn how CSS ::first-letter builds a drop cap, why float and line-height matter, and how each slider value maps to the CSS you get.
  5. Letter Frequency: How the Percentages Are CalculatedSee exactly what the tool counts: percentages use only the letter count, not total characters, and the case option splits the tally into 26 or 52 letters.
  6. English Plural Nouns: Rules, Exceptions, and Quick ChecksLearn how English nouns form plurals with -s, -es, -ies, and -ves, plus irregular pairs like man-men and words like sheep that never change.

Related tools