--- title: matrix() slug: Web/CSS/transform-function/matrix() translation_of: Web/CSS/transform-function/matrix() ---
CSS函数 matrix()
指定了一个由指定的 6 个值组成的 2D 变换矩阵。这种矩阵的常量值是隐含的,而不是由参数传递的;其他的参数是以列优先的顺序描述的。
matrix(a, b, c, d, tx, ty)
是 matrix3d(a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1)
的简写。
matrix(a, b, c, d, tx, ty)
ℝ2 下的笛卡尔坐标 | ℝℙ2 下齐次坐标 | ℝ3下的笛卡尔坐标 | ℝℙ3下的齐次坐标 |
---|---|---|---|
|
b d ty 0 0 1 |
||
[a b c d tx ty] |
这些值表示以下函数:
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; }
请看英文版案例 /zh-CN/docs/Web/CSS/transform-function/matrix#Result