Your Course Progress

Topics
0 / 0
0.00%
Practice Tests
0 / 0
0.00%
Tests
0 / 0
0.00%
Assignments
0 / 0
0.00%
Content
0 / 0
0.00%
% Completed

CSS 2D Transforms

CSS 2D Transforms allow you to manipulate the position, size, and orientation of elements on a web page using transformations.

By applying transforms, you can rotate, scale, skew, and translate elements, allowing for dynamic and engaging visual effects on your web pages. These transformations are done using the transform property, which can take multiple functions, such as rotate() , scale() , translate() , and skew(), to create sophisticated layouts and animations with ease.

The rotate() transform rotates an element around a fixed point. It takes an angle as an argument, which can be expressed in degrees (deg), radians (rad), or gradians (grad).

transform: rotate(45deg); /* Rotate 45 degrees clockwise */

The translate() transform moves an element along the x-axis and y-axis. It takes two arguments: the horizontal displacement (x) and the vertical displacement (y).

transform: translate(100px, 50px); /* Move 100px right and 50px down */

The scale() transform changes the size of an element. It takes two arguments: the horizontal scaling factor (x) and the vertical scaling factor (y).

transform: scale(2, 1); /* Double the width, keep the height the same */

The skew() transform skews an element along the x-axis and y-axis. It takes two arguments: the horizontal skewing angle (x) and the vertical skewing angle (y).

transform: skew(30deg, 20deg); /* Skew 30 degrees horizontally and 20 degrees vertically */
Do You Know?

You can combine multiple transforms by separating them with spaces.

Avoid This

Overusing transforms can negatively impact performance.

Important Note

The transform origin property determines the point around which transforms are applied. The default value is center.

  • CSS 2D Transforms allow you to rotate, translate, scale, and skew elements.
  • Transforms are applied in the order they are specified.
  • The transform origin property controls the point around which transforms are applied.

Discussion