aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/rotate/index.html
blob: 6173e189c995bbdd590ff3c3c31ba6e9b82df108 (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
108
109
110
111
112
113
114
115
116
---
title: rotate
slug: Web/CSS/rotate
translation_of: Web/CSS/rotate
---
<div>{{CSSRef}}{{seecompattable}}{{draft}}</div>

<p><strong><code>rotate</code></strong>属性允许你单独设置<code><strong>transform</strong></code>的旋转属性。这种映射方式可以让我们更方便的设置我们想要的效果,并且避免了简写形式需要记忆属性顺序的不方便之处。</p>

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

<pre class="brush: css notranslate">/* Keyword values */
scale: none;

/* Angle value */
rotate: 90deg;
<span class="css">rotate: 0.25turn;
rotate:</span> <span class="css">1.57rad</span>;

/* x, y, or z axis name plus angle */
rotate: x 90deg;
rotate: y 0.25turn;
rotate: z 1.57rad;

/* Vector plus angle value */
rotate: 1 1 1 90deg;</pre>

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

<dl>
 <dt>角度值</dt>
 <dd>An {{cssxref("&lt;angle&gt;")}} specifying the angle to rotate the affected element through, around the Z axis. Equivalent to a <code>rotate()</code> (2D rotation) function.</dd>
 <dt>x, y 或者 z 轴名称加上角度值</dt>
 <dd>The name of the axis you want to rotate the affected element around (<code>"x"</code>, "<code>y</code>", or "<code>z"</code>), plus an {{cssxref("&lt;angle&gt;")}} specifying the angle to rotate the element through. Equivalent to a <code>rotateX()</code>/<code>rotateY()</code>/<code>rotateZ()</code> (3D rotation) function.</dd>
 <dt>向量加上角度值</dt>
 <dd>Three {{cssxref("&lt;number&gt;")}}s representing an origin-centered vector that defines a line around which you want to rotate the element, plus an {{cssxref("&lt;angle&gt;")}} specifying the angle to rotate the element through. Equivalent to a <code>rotate3d()</code> (3D rotation) function.</dd>
 <dt id="none"><code>none</code></dt>
 <dd>指定不应用旋转</dd>
</dl>

<h3 id="Formal_syntax">Formal syntax</h3>

<pre class="syntaxbox notranslate">{{csssyntax}}</pre>

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

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

<pre class="brush: html notranslate">&lt;div&gt;
  &lt;p class="rotate"&gt;Rotation&lt;/p&gt;
&lt;/div&gt;</pre>

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

<pre class="brush: css notranslate">* {
  box-sizing: border-box;
}

html {
  font-family: sans-serif;
}

div {
  width: 150px;
  margin: 0 auto;
}

p {
  padding: 10px 5px;
  border: 3px solid black;
  border-radius: 20px;
  width: 150px;
  font-size: 1.2rem;
  text-align: center;
}

.rotate {
  transition: rotate 1s;
}

div:hover .rotate {
  rotate: 1 -0.5 1 180deg;
}</pre>

<h3 id="Result">Result</h3>

<p>{{EmbedLiveSample('Examples')}}</p>



<h2 id="Specifications">Specifications</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', '#individual-transforms', 'individual transforms')}}</td>
   <td>{{Spec2('CSS Transforms 2')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<p>{{cssinfo}}</p>

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



<p>{{Compat("css.properties.rotate")}}</p>