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

HTML DOM Style transform property

Style transform property

Style Object Reference The Style object

Example

Rotate a div element:

document.getElementById("myDIV").style.transform="rotate(7deg)";

Try it »


Definition and Usage

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


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 10 and Firefox support the transform property.

Internet Explorer 9 supports another property that can replace this property, namely the msTransform property (used only for 2D transformations).

Opera, Chrome and Safari support another property that can replace this property, namely the WebkitTransform property (available for both 3D and 2D transformations).


Syntax

Return the transform property:

object

.style.transform

Set the transform property:

object

.style.transform="none|

transform-functions

|initial|inherit"

Attribute values

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.
initial Sets this property to its default value. See initial.
inherit Inherits this property from its parent element. See inherit.

Technical Details

Default value: none
Return Value: A string, representing the transform property of an element.
CSS version CSS3

Related Articles

CSS Reference Manual:transform property


Style Object Reference The Style object