What is the matrix() transform function?
初級The matrix() function is a shorthand that combines all 2D transform operations (translate, rotate, scale, skew) into a single 6-value transformation matrix.
Syntax:
transform: matrix(a, b, c, d, tx, ty);| Parameter | Description |
a | Scales horizontally (scaleX) |
b | Skews vertically |
c | Skews horizontally |
d | Scales vertically (scaleY) |
tx | Translates horizontally |
ty | Translates vertically |
Equivalent transformations:
/* These are equivalent */
transform: translate(10px, 20px) rotate(30deg) scale(1.5);
transform: matrix(
1.299, 0.75, /* a, b */
-0.75, 1.299, /* c, d */
10, 20 /* tx, ty */
);> Note: matrix() is mostly used internally by browsers and animation libraries. Prefer individual transform functions for readability.
↥ back to top