CSS 3D Transforms - Detailed Overview

Introduction to 3D Transforms

3D transforms in CSS allow you to manipulate elements in three-dimensional space. The main 3D transform functions include:

Rotate3d

The rotate3d() function rotates an element around a specified axis. Here is an example:

.rotate3d { transform: rotate3d(1, 1, 0, 45deg); }





This element is rotated 45 degrees around the X and Y axes.

Translate3d

The translate3d() function moves an element along the X, Y, and Z axes. Here is an example:

.translate3d { transform: translate3d(50px, 50px, 50px); }
This element is moved 50px along each axis.



Scale3d

The scale3d() function scales an element in three dimensions. Here is an example:

.scale3d { transform: scale3d(1.5, 1.5, 1.5); }
This element is scaled 1.5 times in each dimension.

Perspective

The perspective property defines the perspective from which the 3D space is viewed. Here is an example:

.perspective { transform: rotateX(45deg) rotateY(45deg); }










This element has a perspective of 45 degrees along the X and Y axes.