Tag transform-origin

The transform-origin property defines the point of origin (or pivot point) from which a CSS transformation is applied — especially important for rotatescale, and skew transforms.

It determines where on the element the transformation starts.


🔹 Why Use transform-origin?

Imagine rotating a door:

  • 🛑 If the hinge (origin) is in the middle, the whole door spins.
  • ✅ If the hinge is on the left, it opens like a real door.

That hinge is the transform-origin.


📘 Syntax

selector {
transform-origin: x-axis y-axis [z-axis];
}
  • x-axis: horizontal (left, center, right, or % or px)
  • y-axis: vertical (top, center, bottom, or % or px)
  • z-axis: (optional, for 3D transforms)

💡 Value Examples

ValueWhat It Means
center centerDefault. Transforms around the element’s center.
top leftTransforms from the top-left corner.
100% 0%Right-top corner.
50% 100%Bottom center.
25px 75pxOffset in px from top-left corner.
center center 50pxAdds 3D depth (Z-axis, rarely used)

✍️ Example: Rotate from Top Left

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

✅ The element rotates as if pinned at its top-left corner.


✍️ Example: Zoom from Bottom

.zoom:hover {
transform: scale(1.3);
transform-origin: bottom;
}

✅ The element grows upward, like it’s anchored at the bottom edge.


🖼️ Image Idea: Visual Demo of transform-origin

Image Panel:

  • One square element
  • Rotated 45° from different origins:
    • center
    • top left
    • bottom right

🎯 Purpose: Show how rotation pivots around different parts of the element.


🔁 Combine with transform

.card:hover {
transform: rotate(10deg) scale(1.1);
transform-origin: bottom right;
}

✅ Adds a tilt and zoom effect, anchored from the bottom right corner.


🧠 Pro Tips

  • transform-origin supports percentageskeywords, and pixels.
  • Works on inline-blockblockflex, and grid elements.
  • Use with transition or animation for amazing hover effects.

✅ Summary

Propertytransform-origin
What it controlsPivot/anchor point of transforms
Default valuecenter center
Used withtransformrotatescaleskew
Common valuestop leftcenter50% 100%10px 10px
Useful forAdvanced animations, rotation effects, scaling

🔚 Final Thought

transform-origin gives you precise control over motion and transformation effects. It’s the secret behind natural-feeling spins, zooms, and flips in UI animations.