scale

Term side of the Card.
Topic: Transformations
Unit title: scale
Categories: Property
Explanation side of the Card

Explanation: The property that scales an element in 2D or 3D space by adjusting its size. It doesn't overwrite the `transform` property, as it modifies the element's size without affecting other transform functions. This property is useful for enlarging or shrinking elements to create various visual effects.

Browser compatibility:
  • The chrome browser supports this feature starting from version 104.
  • The edge browser supports this feature starting from version 104.
  • The firefox browser supports this feature starting from version 72.
  • The safari browser supports this feature starting from version 14.1.
Availability: 

Example

Wrongcss
.modal {
  transform: translate(-50%, -50%);
}
.modal:hover {
  transform: scale(1.05);
}
Rightcss
.modal {
  transform: translate(-50%, -50%);
}
.modal:hover {
  scale: 1.05;
}

The scale property stacks with transform, so the modal stays centered while it grows.

Common mistakes

  • Writing scale: 2, 2 with a comma, so it is ignored.
  • A hover transform: scale() wipes out a centering translate(-50%, -50%).

Key points

  • Hover zoom on elements that already have a transform uses the scale property so the existing transform stays.
  • Values in the scale property are space-separated, without commas.

Interview questions

In what order are scale and transform applied?

The browser applies translate, then rotate, then scale, and then the transform property.

Does the scale property use transform-origin?

Yes. Individual transform properties scale around transform-origin, which is the center by default.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy