Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

# scale()

The `scale()` CSS function modifies the size of the element. It can either augment or decrease its size and as the amount of scaling is defined by a vector, it can do so more in one direction than in another one.

This transformation is characterized by a vector whose coordinates define how much scaling is done in each direction. If both coordinates of the vector are equal, the scaling is uniform, or isotropic, and the shape of the element is preserved. In that case, the scaling function defines a homothetic transformation.

When outside the [`-1, 1]` range, the scaling enlarges the element in the direction of the coordinate; when inside the range, it shrinks the element in that direction. When equal to `1` it does nothing and when negative it performs a point reflection and the size modification.

The `scale``()` function only applies the transformation in the Euclidian plane (in 2D). To scale in the space, the `scale3D()` function has to be used.

## Syntax

```scale(sx) or
scale(sx, sy)
```

## Values

sx
Is a `<number>` representing the abscissa of the scaling vector.
sy
Is a `<number>` representing the ordinate of the scaling vector. If not present, its default value is sx, leading to a uniform scaling preserving the shape of the element.
Cartesian coordinates on ℝ2 Homogeneous coordinates on ℝℙ2 Cartesian coordinates on ℝ3 Homogeneous coordinates on ℝℙ3
$\left(\begin{array}{cc}sx& 0\\ 0& sy\end{array}\right)$ $\left(\begin{array}{cc}sx0& 0\\ 0sy& 0\\ 0& 0& 1\end{array}\right)$ $\left(\begin{array}{cc}sx0& 0\\ 0sy& 0\\ 0& 0& 1\end{array}\right)$ $\left(\begin{array}{ccc}sx0& 0& 0\\ 0& sy& 0& 0\\ 0& 0& 1& 0\\ 0& 0& 0& 1\end{array}\right)$
`[sx 0 0 sy 0 0]`

## Examples

### Scaling X dimension

#### HTML

```<p>foo</p>
<p class="transformed">bar</p>```

#### CSS

```p {
width: 50px;
height: 50px;
background-color: teal;
}

.transformed {
/* the same as transform: scaleX(2) scaleY(2);*/
transform: scale(2);
background-color: blue;
}
```

### Scaling X and Y dimensions and translating the origin

#### HTML

```<p>foo</p>
<p class="transformed">bar</p>```

#### CSS

```p {
width: 50px;
height: 50px;
background-color: teal;
}

.transformed {
/* same as scaleX(2) scaleY(0.5) */
transform: scale(2, 0.5);
transform-origin: left;
background-color: blue;
}
```

Tags: