CSS transform-origin Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Transforms

What You’ll Learn

The transform-origin property sets the pivot point for CSS transforms — controlling where rotation, scaling, and skewing appear to happen.

01

Pivot

Origin point.

02

center

Default.

03

Keywords

top left.

04

% / px

Exact spot.

05

rotate

Spin around.

06

scale

Grow from edge.

Introduction

The transform-origin property in CSS is used to change the position of the origin of a transformation. By default, transformations like rotate, scale, and skew are performed around the center of an element.

The transform-origin property allows you to adjust this point to a different location within the element.

Definition and Usage

Use transform-origin when the default center pivot does not look right — for example, a door swinging from a hinge on the left, or an icon scaling from the bottom edge.

💡
Beginner Tip

transform-origin does not move the element by itself. It only changes the anchor point used by transform functions like rotate() and scale().

📝 Syntax

The syntax for the transform-origin property is straightforward. You can specify one, two, or three values to set the origin point along the x-axis, y-axis, and z-axis.

syntax.css
element {
  transform-origin: x-axis y-axis z-axis;
}
  • x-axis — Defines where the transformation’s x-origin is located.
  • y-axis — Defines where the transformation’s y-origin is located.
  • z-axis (optional) — Defines where the transformation’s z-origin is located.

Basic Example

transform-origin.css
.box {
  transform-origin: top left;
  transform: rotate(45deg);
}

Syntax Rules

  • One value sets x; y defaults to center.
  • Two values set x and y. Keywords or lengths are allowed.
  • Three values add a z-axis origin for 3D transforms.
  • Must be paired with a transform to see a visual effect.
  • The property is not inherited.

Related Properties

  • transform — applies the actual rotation, scale, or skew
  • perspective — adds depth for 3D transform origins
  • transform-style — preserves 3D space for child elements
  • transition — animates transform changes smoothly

🎯 Default Value

The default value of the transform-origin property is 50% 50% 0, which means the transformation is performed around the center of the element along the x and y axes, with no offset along the z-axis.

⚡ Quick Reference

QuestionAnswer
Default value50% 50% 0 (center)
Rotate from top-lefttransform-origin: top left;
Scale from bottomtransform-origin: bottom center;
Exact pixel pivottransform-origin: 20px 40px;
Needs transform?Yes
InheritedNo

💎 Property Values

The transform-origin property accepts lengths, percentages, and keywords.

ValueExampleDescription
lengthtransform-origin: 10px 20px;A length value (e.g., 10px, 2em) that defines the origin point.
percentagetransform-origin: 50% 0%;A percentage value relative to the element’s size.
keywordtransform-origin: top left;Keywords such as top, bottom, left, right, and center.
z-axis (optional)transform-origin: center 50% 100px;A length or percentage defining the z-axis origin for 3D transforms.
center top left 50% 50% 10px 20px

When to Use transform-origin

transform-origin matters whenever the pivot point changes the visual effect:

  • Door or panel animations — Rotate from left center like a hinge.
  • Dropdown menus — Scale from top center so they expand downward.
  • Loading spinners — Keep center for symmetric rotation.
  • Card flip effects — Set z-origin for 3D flip animations.

👀 Live Preview

Same rotate(30deg) with different origin points:

center
top left
bottom center

Examples Gallery

In this example, we’ll change the transform origin of a square to the top left corner and rotate it by 45 degrees.

📜 Basic Origins

Change the pivot point and see how the same transform looks different.

Example 1 — Rotate from top left

In this example, we’ll change the transform origin of a square to the top left corner and rotate it by 45 degrees.

index.html
<style>
  .box {
    width: 100px;
    height: 100px;
    background-color: lightblue;
    transform-origin: top left;
    transform: rotate(45deg);
  }
</style>

<div class="box"></div>
Try It Yourself

How It Works

The box spins around its top-left corner instead of its center, creating a hinged rotation effect.

Example 2 — center vs top left

Compare the default center origin with a corner origin using the same rotation angle.

compare.css
.center-spin {
  transform-origin: center;
  transform: rotate(45deg);
}

.corner-spin {
  transform-origin: top left;
  transform: rotate(45deg);
}
Try It Yourself

How It Works

Both boxes use rotate(45deg), but the pivot point completely changes where the shape ends up on screen.

📄 UI Patterns

Choose origins that match how real objects move and grow.

Example 3 — Scale from bottom center

Make a panel grow upward by scaling from the bottom edge.

scale-origin.css
.panel {
  transform-origin: bottom center;
  transform: scaleY(1.2);
}
Try It Yourself

How It Works

The bottom edge stays fixed while the top stretches upward during the vertical scale.

Example 4 — Percentage origin values

Use percentages for precise pivot placement relative to element size.

percent.css
.diamond {
  transform-origin: 50% 100%;
  transform: rotate(45deg);
}
Try It Yourself

How It Works

50% 100% places the pivot at the bottom center — halfway across and at the full height of the box.

♿ Accessibility

  • Reduced motion — Respect prefers-reduced-motion when animating transforms tied to origin changes.
  • Do not disorient users — Extreme rotations from corner origins can feel jarring on large UI blocks.
  • Keep controls predictable — Interactive elements should transform in ways users expect (e.g., buttons scaling from center).
  • Test focus visibility — Transformed elements may shift focus rings unexpectedly.

transform-origin + transform

Always set transform-origin together with a transform function. The origin defines where; the transform defines what happens.

origin-transform.css
.door {
  transform-origin: left center;
  transform: rotateY(-75deg);
  transition: transform 0.4s ease;
}

🧠 How transform-origin Works

1

Element has a transform

A function like rotate() or scale() is applied.

transform
2

Origin point is set

CSS defines the x, y, and optional z pivot with keywords or lengths.

Pivot
3

Transform applies around pivot

The element rotates, scales, or skews relative to that anchor point.

Effect
=

Controlled motion

The same transform feels completely different with a new origin.

Browser Compatibility

The transform-origin property is supported in all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. Ensure that your website is tested across different browsers to confirm compatibility.

Universal · All modern browsers

Reliable pivot control

2D and 3D transform origins work in all current major browsers without vendor prefixes.

99% Browser support
Google Chrome 36+ · Desktop & Mobile
Full support
Mozilla Firefox 16+ · Desktop & Mobile
Full support
Apple Safari 9+ · macOS & iOS
Full support
Microsoft Edge 12+ · All versions
Full support
Opera 23+ · All versions
Full support

Testing tip

Verify 3D flip animations with z-axis origins in Safari and Firefox on mobile devices.

transform-origin property 99% supported

Bottom line: transform-origin is safe to use for transform animations in all modern browsers.

Conclusion

The transform-origin property is an essential tool for web developers looking to create complex and visually engaging transformations.

By adjusting the origin point of transformations, you can achieve a wide range of effects and animations that enhance the user experience. Experiment with different origin points and see how this property can elevate your web designs.

💡 Best Practices

✅ Do

  • Match origin to the real-world motion you want (hinge, dropdown, spinner)
  • Use keywords like top left for readable CSS
  • Pair with transition for smooth animated pivots
  • Test center vs corner origins side by side during design
  • Set z-origin for 3D card flip effects

❌ Don’t

  • Expect visible change without a transform applied
  • Rotate large content blocks from corner origins without good reason
  • Forget that percentage origins are relative to the element box
  • Ignore reduced-motion preferences on animated transforms

Key Takeaways

Knowledge Unlocked

Five things to remember about transform-origin

Use these points when setting pivot points for CSS transforms.

5
Core concepts
02

50% 50% 0

Default center.

Default
🔤 03

top left

Corner pivot.

Keyword
🔀 04

+ transform

Required pair.

Rule
📐 05

px / %

Precise control.

Values

❓ Frequently Asked Questions

transform-origin sets the pivot point around which transform functions like rotate and scale are applied. By default it is the center of the element.
The default is 50% 50% 0, meaning the center of the element on the x and y axes with no z offset.
transform-origin only affects elements that have a transform applied. It defines where the transform happens.
Yes. Keywords such as top, bottom, left, right, and center can define the origin, for example transform-origin: top left.
No, transform-origin is not inherited. Each element sets its own pivot point.

Practice in the Live Editor

Open the HTML editor and compare center vs top-left transform origins on a rotating box.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful