3D Transforms: rotateX rotateY translateZ
Rotate and move elements in three-dimensional space using 3D CSS transform functions.
3D Transforms: rotateX rotateY translateZ is a free CSS Academy lesson on CoddyKit. This is lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CSS Academy learning path, and your progress syncs across the web and the CoddyKit app. The CSS Academy course includes 4 lessons in total.
3D Transform Overview
CSS 3D transforms extend the 2D system into a third dimension using the Z axis. Enable 3D with a perspective on the parent and transform-style: preserve-3d for nested 3D elements.
rotateX()
rotateX(angle) rotates an element around the horizontal X axis — like flipping a page toward or away from you.
<div class="page"><div class="leaf">Leaf</div></div>rotateY()
rotateY(angle) rotates around the vertical Y axis — like turning a door on its hinge.
<div class="card-flip demo-active"><div class="card">Card</div></div>rotateZ()
rotateZ(angle) is identical to the 2D rotate() function — rotation in the plane of the screen.
rotate3d()
rotate3d(x, y, z, angle) rotates around a custom 3D axis vector. The x, y, z values define the direction of the axis.
<div class="element">3D</div>translateZ()
translateZ() moves an element toward or away from the viewer along the Z axis. Positive values come closer; negative values go farther away.
<div class="scene-z">
<div class="layer-front">Front</div>
<div class="layer-back">Back</div>
</div>translate3d()
translate3d(x, y, z) moves an element in all three axes at once. Using translateZ(0) forces GPU layer promotion (a common performance hack).
<div class="animated">GPU layer</div>scale3d()
scale3d(x, y, z) scales in three dimensions. scaleZ() scales depth — useful for 3D cube faces.
3D Cube Example
Building a cube using 3D transforms on six faces:
<div class="cube-scene">
<div class="cube">
<div class="cube-face front">Front</div>
<div class="cube-face back">Back</div>
<div class="cube-face left">Left</div>
<div class="cube-face right">Right</div>
<div class="cube-face top">Top</div>
<div class="cube-face bottom">Bottom</div>
</div>
</div>Parallax 3D Effect
Using translateZ on child elements creates depth in a scrollable 3D scene (CSS Parallax):
<div class="parallax-scene">
<div class="far-layer">Far layer</div>
<div class="close-layer">Close layer</div>
</div>Hardware Acceleration
3D transforms (even trivial ones like translateZ(0)) force the element onto its own GPU layer. This prevents paint during animation but uses GPU memory. Use intentionally, not as a blanket hack.
Quick Check
Which transform function moves an element along the Z axis (toward or away from the viewer)?
Recap
3D CSS transforms use rotateX/Y/Z() for rotation around each axis and translateZ() for depth movement. Enable true 3D with perspective on the parent and transform-style: preserve-3d. Use backface-visibility: hidden for flip effects. 3D transforms force GPU layer promotion for smooth animation.
Learn CSS with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 40
- Lessons
- 159
Frequently Asked Questions
Is the “3D Transforms: rotateX rotateY translateZ” lesson free?
Yes — the full text of “3D Transforms: rotateX rotateY translateZ” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CSS Academy course, upgrade to CoddyKit PRO. The CSS Academy course includes 4 lessons in total.
What will I learn in “3D Transforms: rotateX rotateY translateZ”?
Rotate and move elements in three-dimensional space using 3D CSS transform functions. You practise CSS Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start CSS Academy?
No prior experience is required. CSS Academy on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.
How long does the “3D Transforms: rotateX rotateY translateZ” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this CSS Academy lesson?
Yes. Every CSS Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Translate Rotate and Scale
- Skew and Matrix Transforms
- Transform Origin and Perspective
- 3D Transforms: rotateX rotateY translateZ