CSS rotateZ() Function
The CSS rotateZ() function is used within the
transform property, and defines a 3D rotation of
an element around its z-axis at a given degree.
This means that it spins the element flat on the screen (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 rotateZ() to rotate <div> elements around the z-axis:
.container {
perspective: 500px; /* Creates the 3D space */
}
.box1 {
transform: rotateZ(45deg);
}
.box2 {
transform: rotateZ(80deg);
}
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 | |||||
|---|---|---|---|---|---|
| rotateZ() | 12 | 12 | 10 | 4 | 15 |
CSS Syntax
rotateZ(angle)
| Value | Description |
|---|---|
| angle | Required. Specifies the angle of rotation. Possible units:
|
| Version: | CSS Transforms Module Level 2 |
|---|
More Examples
Example
Use rotateZ() to rotate images around the z-axis:
.container {
perspective: 500px; /* Creates the 3D space */
}
.img1 {
transform: rotateZ(45deg);
}
.img2 {
transform: rotateZ(-60deg);
}
Try it Yourself »
Related Pages
CSS reference: CSS transform property.
CSS reference: CSS perspective property.
CSS reference: CSS rotate3d() function.
CSS reference: CSS rotateX() function.
CSS reference: CSS rotateY() function.
CSS tutorial: CSS 3D transforms.