transform-origin

Avatar of Chris Coyier
Chris Coyier on (Updated on )

The transform-origin property is used in conjunction with CSS transforms, letting you change the point of origin of a transform.

.element {
  transform: rotate(360deg);
  transform-origin: top left;
}

As indicated above, the transform-origin property can take up to two space-separated keyword or length values for a 2D transform and up to three values for a 3D transform.

Using the code above on a 200px by 200px box, with the transform applied to a transitioned using a click event, would behave like this:

By default, the origin of a transform is “50% 50%”, which is exactly in the center of any given element. Changing the origin to “top left” (as in the demo above) causes the element to use the top left corner of the element as a rotation point.

Values can be lengths, percentages or the keywords top, left, right, bottom, and center.

The first value is the horizontal position, the second value is the vertical, and the third value represents the position on the Z axis. The third value will only work if you are using 3D transforms, and it cannot be a percentage.

Browser support

IEEdgeFirefoxChromeSafariOpera
9+All3.5+AllAll11.5+
Android ChromeAndroid FirefoxAndroid BrowseriOS SafariOpera Mobile
AllAll91+AllAll
Source: caniuse