CSS scale Property
Definition and Usage
The scale
property allows you to change the size of elements.
The scale
property defines values for how much an element is scaled in x- and y-directions. You can also define how much an element is scaled in z-direction.
Scale values can be given as one value, two values, or three values.
- If one value is given, the element is scaled the same amount in both x- and y-direction.
- If two values are given, the element is scaled in x- and y-direction individually.
- If three values are given, the element is scaled in x-, y- and z-direction individually.
To better understand the scale
property,
view a demo.
Note: An alternative technique to scale an element is to use CSS transform
property with CSS scale()
function. The CSS scale
property, as explained on this webpage, is arguably a simpler and more direct way to scale an element.
Default value: | none |
---|---|
Inherited: | no |
Animatable: | yes. Read about animatable Try it |
Version: | CSS3 |
JavaScript syntax: | object.style.scale="2 0.7" Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
scale | 104 | 104 | 72 | 14.1 | 90 |
CSS Syntax
scale: x-axis y-axis z-axis|initial|inherit;
Property Values
Property Value | Description | Demo |
---|---|---|
x-axis | Defines scale factor at the x-axis. Possible values:
|
Demo ❯ |
y-axis | Defines scale factor at the y-axis. Possible values:
|
Demo ❯ |
z-axis | Defines scale factor at the z-axis. Possible values:
|
|
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
More Examples
Example
When scale
property is set with two values, the size is set on x-axis and y-axis individually. Here, the element becomes double in size on x-axis and half the size on y-axis:
div {
scale: 2 50%;
}
Try it Yourself »
Related Pages
CSS tutorial: CSS 2D Transforms
CSS tutorial: CSS 3D Transforms
CSS rotate property: CSS Rotate property
CSS translate property: CSS Translate property