scale
Example
.modal {
transform: translate(-50%, -50%);
}
.modal:hover {
transform: scale(1.05);
}.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, 2with a comma, so it is ignored. - A hover
transform: scale()wipes out a centeringtranslate(-50%, -50%).
Key points
- Hover zoom on elements that already have a
transformuses thescaleproperty so the existing transform stays. - Values in the
scaleproperty 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.