Course contentsShow
← Web Development
Lesson 533 of 2,9829. CSS Transitions and AnimationsFree lesson

Transform Origin Point

Controlling the pivot point for transforms using transform-origin with keywords or coordinates.

Transform Origin Point

You'll learn: How to control the pivot point around which CSS transforms rotate, scale, or skew using the transform-origin property.

What Is Transform Origin?

By default, every transform you apply—whether it's a rotation, scale, or skew—happens around the center of the element. The transform-origin property lets you change that pivot point to anywhere you want.

Think of it like a door: if the hinges (origin point) are on the left edge, the door swings open from the left. If you moved the hinges to the center, the door would pivot differently. Same door, different pivot point, completely different motion.

How It Works

The transform-origin property accepts:

  • Keywords: top, bottom, left, right, center
  • Coordinates: Length values (px, %, etc.) for precise positioning
.box {
  transform: rotate(45deg);
  transform-origin: top left; /* Rotates from top-left corner */
}

You can combine keywords or use two values (horizontal, vertical):

.card {
  transform: scale(1.5);
  transform-origin: bottom center; /* Scales from bottom center */
}

.photo {
  transform: rotate(90deg);
  transform-origin: 20px 50%; /* 20px from left, 50% from top */
}

Why It Matters

Without controlling the origin, your animations might feel "off." A card that flips from its center looks different from one that flips from an edge. A scaling button that grows from its top-left corner creates a different visual effect than one growing from its center.

Key Takeaway: The transform-origin property changes where transforms pivot from, giving you precise control over how elements rotate, scale, or skew—use keywords like top right or exact coordinates for pixel-perfect effects.