CSS rotate3d() Function
The CSS rotate3d() function is used within the
transform property, and defines a 3D rotation of
an element around its x, y, and z-axes at a given degree.
Note: To activate a 3D space, the element needs perspective. Without perspective, any 3D transforms will look flat and two-dimensional.
Example
Use rotate3d() to rotate <div> elements:
.container {
perspective: 500px; /* Creates the 3D space */
}
.box1 {
transform: rotate3d(1, 2, 1, 45deg);
}
.box2 {
transform: rotate3d(0, 1, 0, 60deg);
}
.box3 {
transform: rotate3d(1, 0, 0, 45deg);
}
Try it Yourself »
More "Try it Yourself" examples below.
Browser Support
The numbers in the table specify the first browser version that fully supports the function.
| Function | |||||
|---|---|---|---|---|---|
| rotate3d() | 12 | 12 | 10 | 4 | 15 |
CSS Syntax
rotate3d(x, y, z, angle)
| Value | Description |
|---|---|
| x | A positive or negative number that represents the x-coordinate of the rotation vector |
| y | A positive or negative number that represents the y-coordinate of the rotation vector |
| z | A positive or negative number that represents the z-coordinate of the rotation vector |
| angle | Required. Specifies the angle of rotation. Possible units:
|
| Version: | CSS Transforms Module Level 2 |
|---|
More Examples
Example
Use rotate3d() to rotate images:
.container {
perspective: 500px; /* Creates the 3D space */
}
.img1 {
transform: rotate3d(1, 2, 1, 45deg);
}
.img2 {
transform: rotate3d(0, 1, 0, 60deg);
}
.img3 {
transform: rotate3d(1, 0, 0, 45deg);
}
Try it Yourself »
Related Pages
CSS reference: CSS transform property.
CSS reference: CSS perspective property.
CSS reference: CSS rotateX() function.
CSS reference: CSS rotateY() function.
CSS reference: CSS rotateZ() function.
CSS tutorial: CSS 3D transforms.