CSS3 - 3D Transform
CSS3 allows you to format your elements using 3D transforms. In this chapter you will learn about some of the 3D transform methods:
CSS3 3D Transform Browser Support
| Property |
Browser Support |
| transform |
|
|
|
|
|
Internet Explorer, Firefox, and Opera does not yet support the 3D transform methods.
Chrome and Safari requires the prefix -webkit-.
3D rotate
With the rotateX() method, the element rotates around its X-axis at a given degree.
CSS3 rotateX() Example
div
{
transform: rotateX(120deg);
-webkit-transform: rotateX(120deg); /* Safari and Chrome */
}
rotate y-axis
With the rotateY() method, the element rotates around its Y-axis at a given degree.
CSS3 rotateY() Example
div
{
transform: rotateY(130deg);
-webkit-transform: rotateY(130deg); /* Safari and Chrome */
}
3D rotate Z axis
With the rotateZ() method, the element rotates around its Z-axis at a given degree.
CSS3 rotateZ() Example
div
{
transform: rotateZ(120deg);
-webkit-transform: rotateZ(120deg); /* Safari and Chrome */
}
3D rotate
With the rotate3d() method, the element rotates around its X, Y, and Z axis at a given degree.
CSS3 rotate3d() Example
div
{
transform: rotate3d(1,2,1, 45deg);
-webkit-transform: rotate3d(1,2,1, 45deg);
}
| Function |
Description |
matrix3d
(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n) |
Defines a 3D transformation, using a 4x4 matrix of 16 values |
| translate3d(x,y,z) |
Defines a 3D translation |
| translateX(x) |
Defines a 3D translation, using only the value for the X-axis |
| translateY(y) |
Defines a 3D translation, using only the value for the Y-axis |
| translateZ(z) |
Defines a 3D translation, using only the value for the Z-axis |
| scale3d(x,y,z) |
Defines a 3D scale transformation |
| scaleX(x) |
Defines a 3D scale transformation by giving a value for the X-axis |
| scaleY(y) |
Defines a 3D scale transformation by giving a value for the Y-axis |
| scaleZ(z) |
Defines a 3D scale transformation by giving a value for the Z-axis |
| rotate3d(x,y,z,angle) |
Defines a 3D rotation |
| rotateX(angle) |
Defines a 3D rotation along the X-axis |
| rotateY(angle) |
Defines a 3D rotation along the Y-axis |
| rotateZ(angle) |
Defines a 3D rotation along the Z-axis |
| perspective(n) |
Defines a perspective view for a 3D transformed element |