CHAPTER 54
CSS 3D Transforms
Learn how CSS can create three-dimensional rotations, perspective and 3D interfaces.
01. What is CSS 3D Transforms?
3D transforms add depth to CSS elements.
rotateX, rotateY and rotateZ can rotate elements in 3D space.
perspective controls how deep the 3D scene appears.
transform-style: preserve-3d allows child elements to maintain 3D positioning.
02. Syntax
transform: rotateX(45deg);
transform: rotateY(45deg);
transform: perspective(500px);
transform-style: preserve-3d;
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.scene {
perspective: 600px;
}
.card {
width: 180px;
height: 180px;
background: #2563eb;
transition: transform .6s;
}
.card:hover {
transform:
rotateY(40deg)
rotateX(10deg);
}
</style>
</head>
<body>
<div class="scene">
<div class="card"></div>
</div>
</body>
</html>
04. Important Points
✓
perspective creates a sense of depth.
✓
rotateX rotates around the X axis.
✓
rotateY rotates around the Y axis.
✓
rotateZ rotates around the Z axis.
✓
3D effects should remain usable and responsive.
05. Common Mistakes
⚠
Using too much rotation.
⚠
Forgetting perspective.
⚠
Creating effects that cause motion discomfort.
⚠
Making important content difficult to read.
06. Real World Use
3D transforms are useful for premium cards, product previews, interactive portfolios and creative landing pages.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create a 3D Card
Create a card that rotates around the Y axis when the user hovers over it.