CSS3 transform-origin
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The transform-origin
CSS property establish the origin of transformation for an element.
The following table summarizes the usages context and the version history of this property.
Default value: | 50% 50% 0 |
---|---|
Applies to: | Transformable elements |
Inherited: | No |
Animatable: | Yes. See animatable properties. |
Version: | New in CSS3 |
Syntax
The syntax of the property is given with:
Note: If only one value is specified for the transform-origin
property, the second value is assumed to be center
, which is equal to 50%
value.
The example below shows the transform-origin
property in action.
Example
Try this code »img {
/* Chrome, Safari, Opera */
-webkit-transform: rotate(30deg);
-webkit-transform-origin: 25% bottom;
/* Firefox */
-moz-transform: rotate(30deg);
-moz-transform-origin: 25% bottom;
/* IE 9 */
-ms-transform: rotate(30deg);
-ms-transform-origin: 25% bottom;
/* Standard syntax */
transform: rotate(30deg);
transform-origin: 25% bottom;
}
Note: If at least one of the two values is not a keyword, then the first value represents the horizontal position (or offset) and the second value represents the vertical position (or offset) of the transform origin.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
x-position |
Represents the horizontal position (or offset) of the transform origin. It can have one of the following values:
|
y-position |
Represents the vertical position (or offset) of the transform origin. It can have one of the following values:
|
z-position |
A length value describing how far from the user eye the Z = 0 origin is set (for 3D transforms). Percentage values are invalid. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element transform-origin property. |
Browser Compatibility
The transform-origin
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS3 2D Transforms, CSS3 3D Transforms
Related properties: backface-visibility
, perspective
, perspective-origin
, transform
, transform-style
.