CSS3 3D Transform
3D transformation
CSS3 allows you to format elements using 3D transformations.
In this chapter, you will learn some of these 3D transformation methods:
rotateX()
rotateY()
Browser support
The numbers in the table represent the first browser version number that supports the property.
The number immediately preceding -webkit-, -ms- or -moz- is the version number of the first browser that supports the prefixed attribute.
Property | ![]() | ![]() | ![]() | ![]() | ![]() |
---|---|---|---|---|---|
transform | 36.0 12.0 -webkit- | 10.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
transform-origin (three-value syntax) | 36.0 12.0 -webkit- | 10.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
transform-style | 36.0 12.0 -webkit- | 11.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
perspective | 36.0 12.0 -webkit- | 10.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
perspective-origin | 36.0 12.0 -webkit- | 10.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
backface-visibility | 36.0 12.0 -webkit- | 10.0 | 16.0 10.0 -moz- | 4.0 -webkit- | 23.0 15.0 -webkit- |
rotateX() method
The rotateX() method, around which the element is rotated on the X axis by a given degree.
Example
div { transform: rotateX(120deg); -webkit-transform: rotateX(120deg); /* Safari 与 Chrome */ }
rotateY() method
The rotateY() method, around which the element is rotated on the Y axis by a given degree.
Example
div { transform: rotateY(130deg); -webkit-transform: rotateY(130deg); /* Safari 与 Chrome */ }
Transform properties
The following table lists all conversion properties:
Property | Description | CSS |
---|---|---|
transform | Apply a 2D or 3D transformation to an element. | 3 |
transform-origin | Allows you to change the position of the transformed element. | 3 |
transform-style | Specifies how nested elements are displayed in 3D space. | 3 |
perspective | Specifies the perspective effect of 3D elements. | 3 |
perspective-origin | Specifies the bottom position of the 3D element. | 3 |
backface-visibility | Defines whether the element is visible when not facing the screen. | 3 |
3D conversion methods
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) | Define 3D transformations. |
translateX(x) | Defines the 3D transformation, using only the values for the X axis. |
translateY( y ) | Defines a 3D transformation, using only the value for the Y axis. |
translateZ ( z ) | Defines a 3D transformation, using only the value for the Z axis. |
scale3d(x,y,z) | Defines the 3D scaling transformation. |
scaleX(x) | Defines the 3D scaling transformation by giving an X-axis value. |
scaleY(y) | Defines the 3D scaling transformation, by giving a value for the Y axis. |
scaleZ(z) | Defines the 3D scaling transformation, by giving a value for the Z axis. |
rotate3d(x,y,z,angle) | Define 3D rotation. |
rotateX(angle) | Defines the 3D rotation along the X axis. |
rotateY(angle) | Defines the 3D rotation along the Y axis. |
rotateZ(angle) | Defines the 3D rotation along the Z axis. |
perspective(n) | Defines the perspective view of the 3D transform element. |