scale
is a transform function which can be used to scale an
element on a 2D plane.
scale
takes either one or two values to specify the scaling factor for the element. When a single value is
provided, it scales the element uniformly in both X and Y directions. In the example above, the second
block is twice as large in both directions compared to the first block.
When two values are provided, the first value specifies the scaling in X direction while the second value specifies
the scaling in Y direction.
We can also use the scaleX
and scaleY
functions to specify the scaling factor
along the X and Y directions, respectively.
We can also use percentage (%
) values in scale
function. CSS transformations
interpret these percentage values relative to the dimensions of the element
being styled to determine the degree of transformation.
In the example below, we use a value of 50%
in the scale function
to reduce the element's size to half its original dimensions.