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

HTML DOM Style transformOrigin property

Style transformOrigin property

Style Object Reference The Style object

Example

Set the base point position of a rotated element:

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

Try it »


Definition and Usage

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

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

**Note:** This property must be used with transform property.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

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

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

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


Syntax

Return the transformOrigin property:

object

.style.transformOrigin

Set the transformOrigin property:

object

.style.transformOrigin="

x-axis y-axis z-axis

|initial|inherit"

Attribute 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: | | *z-axis* | Defines where the view is placed on the Z-axis (used for 3D transformations). Possible values: | | initial | Sets the property to its default value. See [*initial*](/cssref/css-initial.html). | | inherit | Inherits the property from the parent element. See [*inherit*](/cssref/css-inherit.html). |

    Technical Details

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

    Related Articles

    JavaScript Style object:transform property

    CSS Reference Manual:transform-origin property


    Style Object Reference The Style object