CSS3 transform-origin Property
Example
Set the base point position of a rotated element:
div
{
transform: rotate(45deg);
transform-origin:20% 40%;
-ms-transform: rotate(45deg); /* IE 9 */
-ms-transform-origin:20% 40%; /* IE 9 */
-webkit-transform: rotate(45deg); /* Safari and Chrome */
-webkit-transform-origin:20% 40%; /* 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-origin | |||||
| (two-value syntax) | 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-origin
(three-value syntax) | 36.0
12.0 -webkit- | 10.0 | 16.0
10.0 -moz- | 9.0
4.0 -webkit- | 23.0
15.0 -webkit- |
Property definition and usage
The transform-origin property allows you to change the position of a transformed element.
2D transform elements can change the X and Y axes of an element. 3D transform elements can also change the Z axis.
To better understand the transform-origin property, see thisDemonstrate.
Note: To use this property, you must first use transform attribute.
Tip:Safari/Chrome users: to better understand3D Transformsproperty, see Demonstrate.
| Default value: | 50% 50% 0 |
|---|---|
| Inherited: | no |
| Version: | CSS3 |
| JavaScript syntax: | object.style.transformOrigin="20% 40%" |
Syntax
transform-origin:
x-axis y-axis z-axis
;
| Value | Description |
|---|---|
| x-axis |
Defines where the view is placed on the X-axis. Possible values: |
Defines where the view is placed on the Y axis. Possible values:
- top
- center
- bottom
- length
- %
Defines where the view is placed on the Z axis. Possible values:
- length