CSS transform-origin Property
Example
Set a rotated element's base placement:
transform: rotate(45deg);
transform-origin: 20% 40%;
}
Definition and Usage
The transform-origin property allows you to change the position of transformed elements.
2D transformations can change the x- and y-axis of an element. 3D transformations can also change the z-axis of an element.
To better understand the transform-origin property,
view a demo.
Note: This property must be used together with the transform property.
Tip: To better understand this property for 3D transforms, view a demo.
| Default value: | 50% 50% 0 |
|---|---|
| Inherited: | no |
| Animatable: | yes. Read about animatable Try it |
| Version: | CSS3 |
| JavaScript syntax: | object.style.transformOrigin="0 0" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
| Property | |||||
|---|---|---|---|---|---|
| transform-origin | 36 | 12 | 16 | 9 | 23 |
CSS Syntax
Property Values
| Property Value | Description |
|---|---|
| x-axis | Defines where the view is placed at the x-axis. Possible values:
|
| y-axis | Defines where the view is placed at the y-axis. Possible values:
|
| z-axis | Defines where the view is placed at the z-axis (for 3D transformations). Possible values:
|
| initial | Sets this property to its default value. Read about initial |
| inherit | Inherits this property from its parent element. Read about inherit |
Related Pages
CSS tutorial: CSS 2D Transforms
CSS tutorial: CSS 3D Transforms
HTML DOM reference: transformOrigin property