--- title: rotateY() slug: Web/CSS/transform-function/rotateY() translation_of: Web/CSS/transform-function/rotateY() ---
{{CSSRef}}

rotateY()  函数定义了一个转换,它可以让一个元素围绕纵坐标(垂直轴)旋转,而不会对其进行变形。它的结果是一个{{cssxref("<transform-function>")}} 数据类型。

{{EmbedInteractiveExample("pages/css/function-rotateY.html")}}

旋转轴围绕原点旋转,而这个原点通过{{cssxref("transform-origin")}} 属性来定义。

注意: rotateY(a) 相当于 rotate3d(0, 1, 0, a).

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

语法

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

rotateY(a)

参数值

a
a 是一个{{cssxref("<angle>")}} ,表示旋转的角度。正数角度表示顺时针旋转,负数则表示逆时针旋转。
笛卡儿坐标 ℝ2 齐次坐标 ℝℙ2 笛卡儿坐标 ℝ3 齐次坐标 ℝℙ3
This transformation applies to the 3D space and can't be represented on the plane. cos(a)0sin(a)010-sin(a)0cos(a) cos(a)0sin(a)00100-sin(a)0cos(a)00001

示例

HTML

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

CSS

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

.rotated {
  transform: rotateY(60deg);
  background-color: pink;
}

结果

{{EmbedLiveSample("示例", "auto", 180)}}

规范

Specification Status Comment
{{SpecName("CSS Transforms 2", "#funcdef-rotatey", "rotateY()")}} {{Spec2("CSS Transforms 2")}} Initial definition

浏览器兼容

有关兼容性信息,请参阅 <transform-function> 的数据类型。

另请参阅