CSS AdvancedLesson #132

Scale

The `scale()` function increases or decreases the size of an element (according to the parameters given for the width and height).

The CSS scale() Function

The scale() function increases or decreases the size of an element (according to the parameters given for the width and height).

The following example increases the <div> element to be two times of its original width, and three times of its original height:

<img src="transform_scale.gif" alt="Scale">

Example

Example Code

css
Try it Yourself
div {

  transform: scale(2, 3);

}

The following example decreases the <div> element to be half of its original width and height:

Example

Example Code

css
Try it Yourself
div {

  transform: scale(0.5, 0.5);

}

The CSS scaleX() Function

The scaleX() function increases or decreases the width of an element.

The following example increases the <div> element to be two times of its original width:

Example

Example Code

css
Try it Yourself
div {

  transform: scaleX(2);

}

The following example decreases the <div> element to be half of its original width:

Example

Example Code

css
Try it Yourself
div {

  transform: scaleX(0.5);

}

The CSS scaleY() Function

The scaleY() function increases or decreases the height of an element.

The following example increases the <div> element to be three times of its original height:

Example

Example Code

css
Try it Yourself
div {

  transform: scaleY(3);

}

The following example decreases the <div> element to be half of its original height:

Example

Example Code

css
Try it Yourself
div {

  transform: scaleY(0.5);

}


Interactive Code Examples

CSS Example 1

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 2

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 3

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 4

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 5

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview:

CSS Example 6

css
Try it Yourself
Interactive runnable CSS example from EA Academy.
Live Output Preview: