CSS3 3D Transform
3D Transform
CSS3 allows you to format elements using 3D transforms.
In this chapter, you will learn some of the 3D transform methods:
- rotateX()
- rotateY()
Click on the element below to see the difference between 2D and 3D transforms:
Browser Support
The numbers in the table specify the first browser version that supports the property.
The numbers following -webkit-, -ms-, or -moz- indicate the first browser version that supports the prefixed property.
Property | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
transform | 36.0 <br>12.0 -webkit- | 10.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
transform-origin <br>(three-value syntax) | 36.0 <br>12.0 -webkit- | 10.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
transform-style | 36.0 <br>12.0 -webkit- | 11.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
perspective | 36.0 <br>12.0 -webkit- | 10.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
perspective-origin | 36.0 <br>12.0 -webkit- | 10.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
backface-visibility | 36.0 <br>12.0 -webkit- | 10.0 | 16.0 <br>10.0 -moz- | 4.0 -webkit- | 23.0 <br>15.0 -webkit- |
rotateX() Method
The rotateX() method rotates an element around its X-axis at a given degree.
Example
rotateY() Method
The rotateY() method rotates an element around its Y-axis at a given degree.
Example
div {
transform: rotateY(130deg);
-webkit-transform: rotateY(130deg); /* Safari and Chrome */
}
Transform Properties
The following table lists all the transform properties:
Property | Description | CSS |
---|---|---|
transform | Applies a 2D or 3D transformation to an element. | 3 |
transform-origin | Allows you to change the position of transformed elements. | 3 |
transform-style | Specifies how nested elements are rendered in 3D space. | 3 |
perspective | Specifies the perspective on how 3D elements are viewed. | 3 |
perspective-origin | Specifies the bottom position of 3D elements. | 3 |
backface-visibility | Defines whether or not an element should be visible when not facing the screen. | 3 |
3D Transform Methods
Function | Description |
---|---|
matrix3d( n, n, n, n, n, n, <br> 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 the perspective view for a 3D transformed element. |