CSS PROPERTIES
Expand All|Collapse All
CSS AT-RULES
SPONSORED LINKS

CSS3 transform-origin Property

Topic: CSS3 Properties Reference« Prev|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:

transform-origin: 
x-position | y-position | z-position | initial | inherit
 

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.

  • 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:

  • percentage - Defines the offset relative to the width of the element.
  • length - Defines the offset using a length value.
  • left - Equal to 0% or a zero width.
  • center - Equal to 50% or half the width of the box.
  • right - Equal to 100% or the full box width.
y-position

Represents the vertical position (or offset) of the transform origin. It can have one of the following values:

  • percentage - Defines the offset relative to the height of the element.
  • length - Defines the offset using a length value.
  • top - Equal to 0% or a zero height.
  • center - Equal to 50% or a half the height of the box.
  • bottom - Equal to 100% or the full box height.
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.

Browsers Icon

Basic Support—

  • Firefox (2D) 3.5+, (3D) 10+ -moz-, 16+
  • Chrome (2D) 4+, (3D) 12+ -webkit-, 36+
  • Internet Explorer (2D) 9 -ms-, 10+
  • Apple Safari (2D) 3.2+, (3D) 4+ -webkit-
  • Opera (2D) 10.5+ -o-,
    (2D) (3D) 15+ -webkit-, 23+

Further Reading

See tutorial on: CSS3 2D Transforms, CSS3 3D Transforms

Related properties: backface-visibility, perspective, perspective-origin, transform, transform-style.

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.