CSS propertyTransforms

scale

Enlarges or shrinks an element, independently of the transform property.

Initial value
none
Inherited
No
Animatable
yes, as a number
Applies to
transformable elements
JavaScript
element.style.scale = "1.1"
On this page

Example

#
CSS
.button {
  transition: scale 0.15s;
}

.button:active {
  scale: 0.95;
}
Preview

Definition and usage

#

The scale property changes the visual size of an element. A value of 1 is the natural size, 2 doubles it, and 0.5 halves it. Two values scale horizontally and vertically separately.

Scaling does not change the page layout, so an enlarged element overlaps its neighbours instead of pushing them away. That is exactly what you usually want for hover effects.

A negative value creates a mirror image: scale: -1 1 flips the element horizontally.

Syntax

#
Syntax
scale: none | <number> <number>? <number>?;

Values

#
  • none

    Natural size.
  • 1.4

    Enlarges by 40% on both axes.
  • 0.6

    Shrinks to 60%.
  • 1.6 0.8

    Stretched horizontally, squeezed vertically.
  • -1 1

    mirror

    Mirror image horizontally.

Values in practice

#

none

Natural size.
.demo { scale: none; }

1.4

Enlarges by 40% on both axes.
.demo { scale: 1.4; }

0.6

Shrinks to 60%.
.demo { scale: 0.6; }

1.6 0.8

Stretched horizontally, squeezed vertically.
.demo { scale: 1.6 0.8; }

-1 1

Mirror image horizontally.
.demo { scale: -1 1; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • Slightly shrinking a button in the :active state (0.95-0.98) gives a pleasant pressed feeling.
  • Text in an enlarged element can look blurry. For large size changes, it is better to change the real dimensions.

Related entries

#

Spotted a mistake or missing an example? Write to us.