matrix() - CSS: Cascading Style Sheets 编辑
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.
<length>
value for tx and ty.matrix(a, b, c, d, tx, ty)
Values
- a b c d
- Are
<number>
s describing the linear transformation. - tx ty
- 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 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 | Status | Comment |
---|---|---|
CSS Transforms Level 1 The definition of 'matrix()' in that specification. | Working Draft | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论