CSS - 2D Transform

2D Transform

2D transform in CSS is used to perform simple transformation manipulations (such as move, scale, rotate, etc) in a 2-dimensional area. The transform property is used to define this effect.

2D Transform Methods

translate() - moves the element from its position to the x and y axis values specified.

translateX() - moves the element from its position to the x-axis value specified.

translateY() - moves the element from its position to the y-axis value specified.

rotate() - moves the element in a clockwise or anti-clockwise direction, based on the given value (in degrees).

scale() - increases or decreases the size of the element based on the width and height values specified.

scaleX() - increases or decreases the width of the element based on the value specified.

scaleY() - increases or decreases the height of the element based on the value specified.

skew() - skews the element along the x and y axis based on the values specified (in degrees).

skewX() - skews the element along the x-axis based on the value specified (in degrees).

skewY() - skews the element along the y-axis based on the value specified (in degrees).

note
NOTE:

Skew - To move obliquely (sideways) in a particular direction.


matrix() - uses all the 2d transform methods.

Transform Origin

The transform-origin property is used to change the position or location of the element that is already transformed.

  • Syntax is as follows: transform-origin: x-axis y-axis z-axis | initial/inherit
  • x-axis takes values like: left, center, right, relative and absolute units (%, px, etc).
  • y-axis takes values like: left, center, right, relative and absolute units (%, px, etc).

Transform Style

The transform-style property is used to specify how nested or child elements should be rendered in a 3D space. It is used together with the transform property.

ADVERTISEMENTS

LEARNING IS A CONTINOUS PROCESS - PRACTICE MAKES PERFECT