欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

rotateZ() 有大用

rotateZ() 函数定义了一个转换,它可以让一个元素围绕横Z轴旋转,而不会对其进行变形。它的结果是一个<transform-function>数据类型。

旋转轴围绕原点旋转,而这个原点通过transform-origin 属性来定义。

注意: rotateZ(a) 相当于 rotate(a) or rotate3d(0, 0, 1, a)

注意: 与二维平面上的旋转不同,三维旋转的组合通常是不可交换的。换句话说,三维旋转的应用顺序,将会影响最终结果。

语法

rotateZ() 引起的旋转量由<angle>指定。如果为正,则顺时针方向移动;如果为负,则逆时针方向移动。

rotateZ(a)

参数值

  • a

  • a 是一个<angle> ,表示旋转的角度。正数角度表示顺时针旋转,负数则表示逆时针旋转。

笛卡儿坐标 ℝ2齐次坐标 ℝℙ2笛卡儿坐标 ℝ3齐次坐标 ℝℙ3
This transformation applies to the 3D space and can't be represented on the plane.cos(a)-sin(a)0sin(a)cos(a)0001cos(a)-sin(a)00sin(a)cos(a)0000100001

示例

HTML

<div>Normal</div>
<div class="rotated">Rotated</div>

CSS

div {
  width: 80px;
  height: 80px;
  background-color: skyblue;
}

.rotated {
  transform: rotateZ(45deg);
  background-color: pink;
}

结果

规范


来自   https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-function/rotateZ

普通分类: