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

Combining Multiple Transforms

Chaining multiple transform functions in a single declaration and understanding the order of operations.

Combining Multiple Transforms

You'll learn how to chain multiple transform functions together and why the order matters.

The Core Idea

Just like you learned with individual transform functions (translate(), rotate(), scale(), skew()), you can apply multiple transforms to a single element by listing them in one transform declaration. The key insight: transforms apply from right to left, and the order dramatically changes the final result.

Think of it like giving directions to a friend: "Walk forward 10 steps, then turn right" produces a very different destination than "Turn right, then walk forward 10 steps."

How It Works

.element {
  transform: translate(50px, 0) rotate(45deg) scale(1.5);
}

The browser reads this right to left:

  1. First, it scales the element to 1.5× its size
  2. Then rotates it 45 degrees
  3. Finally translates it 50px to the right

If you reversed the order to scale(1.5) rotate(45deg) translate(50px, 0), the translation would happen after rotation, moving the element in a diagonal direction instead of purely horizontal.

Why Order Matters

Each transform creates a new coordinate system for the next transform. When you rotate first, you're rotating the element's local axes, so a subsequent translate() moves along those tilted axes, not the original horizontal/vertical grid.

Practical Example

.card {
  transform: translateX(100px) rotate(15deg);
  /* Moves right 100px, THEN tilts */
}

Key Takeaway: When combining transforms, list them in a single transform property and remember they execute right to left—the order fundamentally changes the visual result.