CSS - scaleX()

The scaleX() CSS function modifies the abscissa of each element point by a constant factor, except if this scale factor is 1, in which case the function is the identity transform. The scaling is not isotropic and the angles of the element are not conserved.

Examples

Without changing the origin

HTML

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

CSS

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

.transformed {
transform: scaleX(2);
background-color: blue;
}

Translating the origin of the transformation

HTML

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

CSS

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

.transformed {
transform: scaleX(2);
transform-origin: left;
background-color: blue;
}

CSS
scaleX(s)

Description

The scaleX() CSS function modifies the abscissa of each element point by a constant factor, except if this scale factor is 1, in which case the function is the identity transform. The scaling is not isotropic and the angles of the element are not conserved. scaleX(sx) is a shorthand for scale(sx, 1) or for scale3d(sx, 1, 1).

scaleX(-1) defines an axial symmetry with a vertical axis passing by the origin (as specified by the transform-origin property).

s
Is a <number> representing the scaling factor to apply on the abscissa of each point of the element.
Cartesian coordinates on ℝ2 Homogeneous coordinates on ℝℙ2 Cartesian coordinates on ℝ3 Homogeneous coordinates on ℝℙ3
$\left(\begin{array}{cc}s& 0\\ 0& 1\end{array}\right)$ $\left(\begin{array}{cc}s0& 0\\ 01& 0\\ 0& 0& 1\end{array}\right)$ $\left(\begin{array}{cc}s0& 0\\ 01& 0\\ 0& 0& 1\end{array}\right)$ $\left(\begin{array}{ccc}s0& 0& 0\\ 01& 0& 0\\ 0& 0& 1& 0\\ 0& 0& 0& 1\end{array}\right)$
[s 0 0 1 0 0]