--- title: matrix() slug: Web/CSS/transform-function/matrix() translation_of: Web/CSS/transform-function/matrix() ---
A função CSS matrix()
define uma matriz de transformação 2D homogênea. Isso resulta em um dado do tipo {{cssxref("<transform-function>")}} .
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)
.
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)
Cartesian coordinates on ℝ2 | Homogeneous coordinates on ℝℙ2 | Cartesian coordinates on ℝ3 | Homogeneous coordinates on ℝℙ3 |
---|---|---|---|
[a b c d tx ty] |
The values represent the following functions:
matrix( scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() )
<div>Normal</div> <div class="changed">Changed</div>
div { width: 80px; height: 80px; background-color: skyblue; } .changed { transform: matrix(1, 2, -1, 1, 80, 80); background-color: pink; }
{{EmbedLiveSample("Examples", 350, 350)}}
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS3 Transforms", "#funcdef-transform-matrix", "matrix()")}} | {{Spec2("CSS3 Transforms")}} | Initial definition |
Please see the <transform-function>
data type for compatibility info.
matrix3d()