matrix()
Quick Summary for matrix()
The
matrix()
CSS function defines a homogeneous 2D transformation matrix. Its result is a <transform-function>
data type.
Code Usage for matrix()
matrix(a, b, c, d, tx, ty)
More Details for matrix()
matrix()
The matrix()
CSS function defines a homogeneous 2D transformation matrix. Its result is a <transform-function>
data type.
Note: matrix(a, b, c, d, tx, ty)
is a shorthand for matrix3d(a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1)
.
Syntax
The matrix()
function is specified with six values. The constant values are implied and not passed as parameters; the other parameters are described in the column-major order.
matrix(a, b, c, d, tx, ty)
Values
a b c dAre <number>
s describing the linear transformation.
Are <number>
s describing the translation to apply.
Cartesian coordinates on ℝ^2 | Homogeneous coordinates on ℝℙ^2 | Cartesian coordinates on ℝ^3 | Homogeneous coordinates on ℝℙ^3 |
---|---|---|---|
( a c b d ) | ( a c tx b d ty 0 0 1 ) | ( a c tx b d ty 0 0 1 ) | ( a c 0 tx b d 0 ty 0 0 1 0 0 0 0 1 ) |
[a b c d tx ty] |
The values represent the following functions: matrix( scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() )
Examples
HTML
<div>Normal</div> <div class="changed">Changed</div>
CSS
div { width: 80px; height: 80px; background-color: skyblue; } .changed { transform: matrix(1, 2, -1, 1, 80, 80); background-color: pink; }
Result
Specifications
Specification |
---|
CSS Transforms Module Level 1 # funcdef-transform-matrix |
See also
transform
<transform-function>
matrix3d()
Understanding the CSS Transforms Matrix Last modified: Jan 31, 2022, by MDN contributors
Select your preferred language English (US)Français日本語한국어PolskiPortuguês (do Brasil)中文 (简体) Change language Posted in
12:22 am, February 22, 2022
Add Comment
Other Items in CSS
rgb()
rgba()
:right
right
@right-bottom
:root
rotate
rotate()
rotate3d()
rotateX()
rotateY()
rotateZ()
row-gap
ruby-align
ruby-position
saturate()
scale
scale()
scale3d()
scaleX()
scaleY()
scaleZ()
:scope
scroll-behavior
scroll-margin
scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
@scroll-timeline