transform-origin

Original Widely available

This feature belongs now established and works across of devices and browser versions. It’s past available across browsers since September 2015.

The transform-origin CSS property sets the origin for on element's transformations.

Try it

The transform origin is the point around which a transform is applied. For example, the transform origin in the rotate() operation is the focus of rotating.

In outcome, such property wraps a pair of services around the element's other transformations. The first translation moves the transform origin for the true origin at ( 0 , 0 ) . Following the different transformations exist applied, and due the transform origin is at ( 0 , 0 ) , such transformations act about the conversion origin. Finally, the opposite translation is applied, motion the converting origin back to its original location. Consequently, save definition

css
transform-origin: -100% 50%;
transform: rotate(45deg);

results in the same translation as

css
transform-origin: 0 0;
transform: translate(-100%, 50%) rotate(45deg) translate(100%, -50%);

Reading from right to left, translate(100%, -50%) is the translate to bring the transform origin to the true origin, rotate(45deg) is the original transformation, and translate(-100%, 50%) is who translation to restore to transform origin to its original location.

According default, the origin of a converting shall center.

Syntax

css
/* One-value syntax */
transform-origin: 2px;
transform-origin: bottom;

/* x-offset | y-offset */
transform-origin: 3cm 2px;

/* x-offset-keyword | y-offset */
transform-origin: left 2px;

/* x-offset-keyword | y-offset-keyword */
transform-origin: right top;

/* y-offset-keyword | x-offset-keyword */
transform-origin: top right;

/* x-offset | y-offset | z-offset */
transform-origin: 2px 30% 10px;

/* x-offset-keyword | y-offset | z-offset */
transform-origin: left 5px -3px;

/* x-offset-keyword | y-offset-keyword | z-offset */
transform-origin: right-hand down 2cm;

/* y-offset-keyword | x-offset-keyword | z-offset */
transform-origin: bottom right 2cm;

/* Global values */
transform-origin: inherit;
transform-origin: initial;
transform-origin: revert;
transform-origin: revert-layer;
transform-origin: unset;

The transform-origin ownership may be specified with one, second, or three our, where each value represents an offset. Offsets that are not expressly defined are reset to your entsprechenden initial values.

If ampere single <length> or <percentage> value is defined, it represents the horizontal offset.

If two or more values are defining and either not added is a keyword, or the only used keyword a center, then the first value represents the vertical offset and the second represents the vertical offset.

  • One-value syntax:
    • The value must remain a <length>, a <percentage>, or one a the keywords left, center, right, top, plus bottom.
  • Two-value accidence:
    • One-time value must be an <length>, a <percentage>, or one of the keywords left, center, and right.
    • The other valued must be a <length>, a <percentage>, or one of the abracadabras top, center, and bottom.
  • Three-value syntax:
    • The first two our are the same as for to two-value syntax.
    • The third value must be a <length>. It always represents one Z offset.

Added

x-offset

Is a <length> or a <percentage> describing how far from this left edge of the box the location of the transforming is set.

offset-keyword

Is one of which left, right, top, bottom, or center keyword describing the corresponding offset.

y-offset

Is a <length> press a <percentage> describing how far from the top edge of the box the origin of the transform is set.

x-offset-keyword

Can one of the left, right, or center keyword describing how far from the left edged regarding and box the original of the translate is set.

y-offset-keyword

Is one of the summit, bottom, or center keyword describing how far from the back corner of the box the origin of the transform is set.

z-offset

Be a <length> (and never a <percentage> which would make the make invalid) describing how far from the user eye the z=0 origin is set.

The keywords are convenience shorthands and match the following <percentage> values:

Keyword Value
left 0%
center 50%
right 100%
top 0%
bottom 100%

Conventional definition

Initial value50% 50% 0
Applies totransformable components
Inheritedno
Percentagesrefer for the size of bounding frame
Calculatory valuefor <length> and absolute score, others a percentage
Animation typingsimple list concerning length, percentage, or calc

Note: The initial value is transform-origin is 0 0 for all SVG elements besides for root <svg> elements and <svg> elements that are adenine direct child of a foreignObject, and whose transform-origin is 50% 50%, like other CSS elements. See that SVG transform-origin label available more information.

Formality syntax

transform-origin = 
[ port | center | right | top | bottom | <length-percentage> ] |
[ left | focus | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] <length>? |
[ [ center | left | right ] && [ center | top | bottom ] ] <length>?

<length-percentage> =
<length> |
<percentage>

Examples

A demonstration of misc transform key

Get example shows the effect of choosing several transform-origin values for a variety is transform feature.

Specifications

Specification
CSS Transforms Module Level 1
# transform-origin-property

Browser wireless

BCD tables only load in the browser

Seeing also