aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/transform-function/rotatez()/index.html
blob: b7fc6b5da20662a4a49bbb3ba739cfdadfd16c0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
title: rotateZ()
slug: Web/CSS/transform-function/rotateZ()
translation_of: Web/CSS/transform-function/rotateZ()
---
<div>{{CSSRef}}</div>

<p><strong><code>rotateZ() </code></strong>函数定义了一个转换,它可以让一个元素围绕横Z轴旋转,而不会对其进行变形。它的结果是一个{{cssxref("&lt;transform-function&gt;")}}数据类型。</p>

<div>{{EmbedInteractiveExample("pages/css/function-rotateZ.html")}}</div>



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

<div class="note">
<p><strong>注意:</strong> <code>rotateZ(a)</code> 相当于 <code><a href="/en-US/docs/Web/CSS/transform-function/rotate">rotate</a>(a)</code> or <code><a href="/en-US/docs/Web/CSS/transform-function/rotate3d">rotate3d</a>(0, 0, 1, a)</code></p>
</div>

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

<h2 id="语法">语法</h2>

<p><strong><code>rotateZ() </code></strong>引起的旋转量由{{cssxref("&lt;angle&gt;")}}指定。如果为正,则顺时针方向移动;如果为负,则逆时针方向移动。</p>

<pre class="syntaxbox">rotateZ(<em>a</em>)
</pre>

<h3 id="参数值">参数值</h3>

<dl>
 <dt><code>a</code></dt>
 <dd><code>a</code> 是一个{{cssxref("&lt;angle&gt;")}} ,表示旋转的角度。正数角度表示顺时针旋转,负数则表示逆时针旋转。</dd>
</dl>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">笛卡儿坐标 ℝ<sup>2</sup></th>
   <th scope="col">齐次坐标 ℝℙ<sup>2</sup></th>
   <th scope="col">笛卡儿坐标 ℝ<sup>3</sup></th>
   <th scope="col">齐次坐标 ℝℙ<sup>3</sup></th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td colspan="2" rowspan="2">This transformation applies to the 3D space and can't be represented on the plane.</td>
   <td colspan="1" rowspan="2"><math> <mfenced><mtable><mtr><mtd>cos(a)</mtd><mtd>-sin(a)</mtd><mtd>0</mtd></mtr><mtr><mtd>sin(a)</mtd><mtd>cos(a)</mtd><mtd>0</mtd></mtr><mtr><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd></mtr></mtable> </mfenced> </math></td>
   <td colspan="1" rowspan="2"><math> <mfenced> <mtable> <mtr><mtd>cos(a)</mtd><mtd>-sin(a)</mtd><mtd>0</mtd><mtd>0</mtd></mtr> <mtr><mtd>sin(a)</mtd><mtd>cos(a)</mtd><mtd>0</mtd><mtd>0</mtd></mtr> <mtr><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd><mtd>0</mtd></mtr> <mtr><mtd>0</mtd><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd></mtr> </mtable> </mfenced> </math></td>
  </tr>
 </tbody>
</table>

<h2 id="示例">示例</h2>

<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;div&gt;Normal&lt;/div&gt;
&lt;div class="rotated"&gt;Rotated&lt;/div&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css">div {
  width: 80px;
  height: 80px;
  background-color: skyblue;
}

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

<h3 id="结果">结果</h3>

<p>{{EmbedLiveSample("示例", "auto", 180)}}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("CSS Transforms 2", "#funcdef-rotatez", "rotateZ()")}}</td>
   <td>{{Spec2("CSS Transforms 2")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容">浏览器兼容</h2>

<p>有关兼容性信息,请参阅 <code><a href="/en-US/docs/Web/CSS/transform-function#Browser_compatibility">&lt;transform-function&gt;</a></code> 的数据类型。</p>

<h2 id="另请参阅">另请参阅</h2>

<ul>
 <li>{{cssxref("transform")}}</li>
 <li>{{cssxref("&lt;transform-function&gt;")}}</li>
</ul>