2D Transforms

suggest change

Syntax

Parameters

Function/Parameter | Details | —— | —— |rotate(x) | Defines a transformation that moves the element around a fixed point on the Z axis |translate(x,y) | Moves the position of the element on the X and Y axis |translateX(x) | Moves the position of the element on the X axis |translateY(y) | Moves the position of the element on the Y axis |scale(x,y) | Modifies the size of the element on the X and Y axis |scaleX(x) | Modifies the size of the element on the X axis |scaleY(y) | Modifies the size of the element on the Y axis |skew(x,y) | Shear mapping, or transvection, distorting each point of an element by a certain angle in each direction |skewX(x) | Horizontal shear mapping distorting each point of an element by a certain angle in the horizontal direction |skewY(y) | Vertical shear mapping distorting each point of an element by a certain angle in the vertical direction |matrix() | Defines a 2D transformation in the form of a transformation matrix. | angle | The angle by which the element should be rotated or skewed (depending on the function with which it is used). Angle can be provided in degrees (deg), gradians (grad), radians (rad) or turns (turn). In skew() function, the second angle is optional. If not provided, there will be no (0) skew in Y-axis. | length-or-percentage | The distance expressed as a length or a percentage by which the element should be translated. In translate() function, the second length-or-percentage is optional. If not provided, then there would be no (0) translation in Y-axis. | scale-factor | A number which defines how many times the element should be scaled in the specified axis. In scale() function, the second scale-factor is optional. If not provided, the first scale-factor will be applied for Y-axis also. |

Remarks

2D Coordiante system

Transforms are made according to a 2D X/Y coordiante system. The X axis goes from right to left and the Y axis goes downwards as shown in the following image:

So a positive translateY() goes downwards and a positive translateX() goes right.

Browser support and prefixes

Example of prefixed transform:

-webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
        transform: rotate(45deg);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents