CSS – 2D Transform

To move and rotate elements on a web page, use the transform property for transformation. With that, you can also scale and skew elements easily. The transform property is used with some methods to accomplish tasks. Let us see the methods with examples:

  • rotate(): Rotate an element
  • scale(): Scale an element
  • scaleX(): Scale the width of an element
  • scaleY(): Scale the height of an element
  • skew(): Skew an element by X and Y axis
  • skewX(): Skew an element by X axis
  • skewY(): Skew an element by Y axis

Rotate an element

To rotate an element on a web page, use the rotate() method. Set the parameter to the degree to which you want to rotate the element. For clockwise rotation, use a positive degree, for example:

For counter-clockwise rotation, use a negative degree:

Let us now see an example to rotate an element in CSS:

Output

CSS 2D Transform Rotate an Element

Scale an element

To scale an element in CSS, use the scale() method. The 1st parameter is to increase or decrease the width and the 2nd is for height.

Let us now see an example to scale i.e. increase or decrease the height and width of an element in CSS:

Output

CSS 2D Transform Scale an Element

scaleX()

To scale only the width of an element on a web page, use the scaleX() method in CSS. Let us now see an example:

Output

CSS 2D Transform scaleX()

scaleY()

To scale only the height of an element on a web page, use the scaleY() method in CSS. Let us now see an example:

Output

CSS 2D Transform scaleY()

skew()

To skew an element by X and Y axis, use the skew() method. Set the angles as the two parameters of the method. Let us see an example:

Output

CSS 2D Transform skew()

skewX()

To skew an element by X axis, use the skewX() method. Set the angle as the parameter of the method. Let us see an example:

Output

CSS 2D Transform skewX()

skewY()

To skew an element by the Y axis, use the skewY() method. Set the angle as the parameter of the method. Let us see an example:

Output

CSS 2D Transform skewY()

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


Read More:

CSS - 3D Transform
CSS Rounded Corners
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading