HTML DOM Style transformOrigin Property
-- Learning not just technology, but dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
JavaScript Reference
Overview (JavaScript and HTML DOM Reference)
JavaScript Objects
- JavaScript Array Object
- JavaScript Boolean Object
- JavaScript Date Object
- JavaScript Math Object
- JavaScript Number Object
- JavaScript String Object
- JavaScript RegExp Object
- JavaScript Global Properties/Functions
- JavaScript Operators
- JavaScript Error
Browser Objects
DOM Objects
- HTML DOM Document Object
- HTML DOM Element Object
- HTML DOM Attribute Object
- HTML DOM Event Object
- HTML DOM Console Object
- CSSStyleDeclaration Object
- DOM HTMLCollection
HTML Objects
- <a>
- <area>
- <audio>
- <base>
- <blockquote>
- <body>
- <button>
- <canvas>
- <col>
- <colgroup>
- <datalist>
- <del>
- <details>
- <dialog>
- <embed>
- <fieldset>
- <form>
- <iframe>
- <frameset>
- <img>
- <ins>
- <input> - button
- <input> - checkbox
- <input> - color
- <input> - date
- <input> - datetime
- <input> - datetime-local
- <input> - email
- <input> - file
- <input> - hidden
- <input> - image
- <input> - month
- <input> - number
- <input> - range
- <input> - password
- <input> - radio
- <input> - reset
- <input> - search
- <input> - submit
- <input> - text
- <input> - time
- <input> - url
- <input> - week
- <keygen>
- <link>
- <label>
- <legend>
- <li>
- <map>
- <menu>
- <menuItem>
- <meta>
- <meter>
- <object>
- <ol>
- <optgroup>
- <option>
- <param>
- <progress>
- <q>
- <script>
- <select>
- <source>
- <style>
- <table>
- <td>
- <th>
- <tr>
- <textarea>
- <title>
- <time>
- <track>
- <video>
Style transformOrigin Property
Example
Set the base point position of a rotated element:
document.getElementById("myDIV").style.transformOrigin="0 0";
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 the transform property.
Browser Support
Internet Explorer 10, Firefox, and Opera support the transformOrigin property.
Internet Explorer 9 supports an alternative property to this one, the msTransformOrigin property (only for 2D transforms).
Chrome, Safari, and Opera support an alternative property to this one, 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. See initial. |
| inherit | Inherits this property from its parent element. See inherit. |
Technical Details
| Default Value: | 50% 50% 0 |
|---|---|
| Return Value: | A string, representing the element's transform-origin property. |
| CSS Version: | CSS3 |
Related Articles
JavaScript Style Object: transform Property
CSS Reference: transform-origin Property
YouTip