Change the width and height of element using CSS



Use the scale() method to change the width and height of the element with CSS.

Let us see the syntax −

scale(x,y);

Here, x is a number representing the abscissa of the scaling vector.

y is a number representing the ordinate of the scaling vector.

Let us see an example −

div {
   width: 40px;
   height: 50px;
   background-color: black;
}
   .myScaled {
   transform: scale(0.4);
   background-color: orange;
}

Advertisements