Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS3 transform Property

CSS3 transform Property

Example

Rotate a div element:

div

{

transform:

rotate

(

7

deg

)

; -

ms-transform:

rotate

(

7

deg

)

;

/*

IE 9

*/

webkit-transform:

rotate

(

7

deg

)

;

/*

Safari and Chrome

*/

}

Try it »


Browser support

The numbers in the table indicate the first browser version that supports this property.

A number immediately before -webkit-, -ms-, or -moz- indicates the first browser version that supports that prefixed property.

property
transform (2D) 36.0
4.0 -webkit- 10.0
9.0 -ms- 16.0
3.5 -moz- 9.0
3.2 -webkit- 23.0
 15.0 -webkit-       
 10.5 -o- |

| transform (3D) | 36.0
12.0 -webkit- | 12.0 | 10.0 | 16.0
10.0 -moz- | 9.0
4.0 -webkit- |


Property definition and usage

The transform property applies a 2D or 3D transform to an element. This property allows you to rotate, scale, move, skew, and so on.

To better understand the transform property, see Online example.

Default value: none
Inherited: no
Version: CSS3
JavaScript syntax: object.style.transform="rotate(7deg)"

Syntax

transform: none|

transform-functions

;

Value Description
none Defines no transformation.
matrix(n,n,n,n,n,n) Defines a 2D transformation, using a matrix of six values.
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.
translate(x,y) Defines a 2D transformation.
translate3d(x,y,z) Defines a 3D transformation.
translateX(x) Defines a transformation, using only the X-axis value.
translateY(y) Defines a transformation, using only the Y-axis value.
translateZ(z) Defines a 3D transformation, using only the Z-axis value.
scale(x[,y]?) Defines a 2D scaling transformation.
scale3d(x,y,z) Defines a 3D scaling transformation.
scaleX(x) Defines a scaling transformation by setting the X-axis value.
scaleY(y) Defines a scaling transformation by setting the Y-axis value.
scaleZ(z) Defines a 3D scaling transformation by setting the Z-axis value.
rotate(angle) Defines a 2D rotation, with the angle specified in the parameter.
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.
skew(x-angle,y-angle) Defines a 2D skew transformation along the X and Y axes.
skewX(angle) Defines a 2D skew transformation along the X-axis.
skewY(angle) Defines a 2D skew transformation along the Y-axis.
perspective(n) Defines a perspective view for 3D-transformed elements.

More examples

Rotate an image
This example demonstrates how to create a "polaroid" photo and rotate the image.

CSS3 Transform - various transformations and rotations