CSS3 3D Transforms
CSS3 3D Transforms
CSS3 allows you to format your elements using 3D transformations.
Mouse over the elements below to see the difference between a 2D
and a 3D transformation:
2D rotate
3D rotate
Browser Support for 3D Transforms
The numbers in the table specify the first browser version that fully supports the property.Numbers followed by -webkit-, -moz-, or -o- specify the first version that worked with a prefix.
| Property | |||||
|---|---|---|---|---|---|
| transform | 10.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
| transform-origin (three-value syntax) |
10.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
| transform-style | 11.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
| perspective | 10.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
| perspective-origin | 10.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
| backface-visibility | 10.0 | 36.0 12.0 -webkit- |
16.0 10.0 -moz- |
4.0 -webkit- | 23.0 15.0 -webkit- |
CSS3 3D Transforms
In this chapter you will learn about the following 3D transformation methods:- rotateX()
- rotateY()
- rotateZ()
The rotateX() Method
The rotateX() method rotates an element around its X-axis at a given degree:Example
div
{
-webkit-transform: rotateX(150deg); /* Safari */
transform: rotateX(150deg);
}
-webkit-transform: rotateX(150deg); /* Safari */
transform: rotateX(150deg);
}
The rotateY() Method
The rotateY() method rotates an element around its Y-axis at a given degree:Example
div
{
-webkit-transform: rotateY(130deg); /* Safari */
transform: rotateY(130deg);
}
-webkit-transform: rotateY(130deg); /* Safari */
transform: rotateY(130deg);
}
The rotateZ() Method
The rotateZ() method rotates an element around its Z-axis at a given degree:Example
div
{
-webkit-transform: rotateZ(90deg); /* Safari */
transform: rotateZ(90deg);
}
-webkit-transform: rotateZ(90deg); /* Safari */
transform: rotateZ(90deg);
}
3D Transform 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) | 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 |
No comments:
Post a Comment