Style transformOrigin Property

Style 对象参考手册Style Object

Example

Set the base point position of the rotated element:

document.getElementById("myDIV").style.transformOrigin="0 0";

Try it Yourself »

Definition and Usage

The transformOrigin property allows you to change the position of transformed elements.

2D transformed elements can change the X and Y axes of the element. 3D transformed elements can also change the Z axis of the element.

Note:This property must be used together with thetransformproperty.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

Internet Explorer 10, Firefox, and Opera support the transformOrigin property.

Internet Explorer 9 supports an alternative property, namely the msTransformOrigin property (only for 2D transforms).

Chrome, Safari, and Opera support an alternative property, namely the WebkitTransformOrigin property (can be used for 3D and 2D transforms).


Syntax

Return the transformOrigin property:

object.style.transformOrigin

Set the transformOrigin property:

object.style.transformOrigin="x-axis y-axis z-axis|initial|inherit"

Property Values

Value Description
x-axis Defines where the view is placed on the X axis. Possible values:
  • left
  • center
  • right
  • length
  • %
y-axis Defines where the view is placed on the Y axis. Possible values:
  • top
  • center
  • bottom
  • length
  • %
z-axis Defines where the view is placed on the Z axis (for 3D transforms). Possible values:
  • length
initial Sets this property to its default value. Seeinitial。
inherit Inherits this property from its parent element. Seeinherit。

Technical Details

Default value: 50% 50% 0
Return value: A string representing the transform-origin property of the element.
CSS Version CSS3


Related Articles

JavaScript Style Object:transform property

CSS Reference Manual:transform-origin property


Style 对象参考手册Style Object

Other Extensions