diff options
Diffstat (limited to 'files/zh-cn/web/css/transform-function/rotate3d/index.html')
-rw-r--r-- | files/zh-cn/web/css/transform-function/rotate3d/index.html | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/transform-function/rotate3d/index.html b/files/zh-cn/web/css/transform-function/rotate3d/index.html new file mode 100644 index 0000000000..1dab01c6aa --- /dev/null +++ b/files/zh-cn/web/css/transform-function/rotate3d/index.html @@ -0,0 +1,128 @@ +--- +title: rotate3d() +slug: Web/CSS/transform-function/rotate3d +tags: + - 3D + - CSS + - CSS Transforms +translation_of: Web/CSS/transform-function/rotate3d() +original_slug: Web/CSS/transform-function/rotate3d() +--- +<div>{{CSSRef}}</div> + +<p><strong><code>rotate3d()</code></strong> CSS函数定义一个变换,它将元素围绕固定轴移动而不使其变形。运动量由指定的角度定义; 如果为正,运动将为顺时针,如果为负,则为逆时针。</p> + +<div>{{EmbedInteractiveExample("pages/css/rotate3d.html")}}</div> + + + +<p>在3D空间之中,旋转有3个自由维度,描述了旋转轴。旋转轴由一组 [x, y, z] 矢量定义,并且通过变换源点传递(即通过 {{ cssxref("transform-origin") }} CSS 属性定义)。如果这些矢量被赋予非标准值,即3个坐标值的平方和不等于1时,它将会被内部隐式标准化。非标准矢量,例如空值和 [0, 0, 0],将会使旋转不起作用,但是不影响整个CSS属性的其他效果(译者注:如transform中的多项变换)。</p> + +<div class="note">与平面旋转相反的是,3D旋转的组合通常是不可交换的;这意味着定义旋转规则的值的顺序是严格控制的。</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox notranslate">rotate3d(<em>x</em>, <em>y</em>, <em>z</em>, <em>a</em>) +</pre> + +<h3 id="值">值</h3> + +<dl> + <dt><em>x</em></dt> + <dd> {{cssxref("<number>")}} 类型,可以是0到1之间的数值,表示旋转轴X坐标方向的矢量。</dd> + <dt><em>y</em></dt> + <dd>{{cssxref("<number>")}} 类型, 可以是0到1之间的数值,表示旋转轴Y坐标方向的矢量。</dd> + <dt><em>z</em></dt> + <dd>{{cssxref("<number>")}} 类型, 可以是0到1之间的数值,表示旋转轴Z坐标方向的矢量。</dd> + <dt><em>a</em></dt> + <dd> {{ cssxref("<angle>") }} 类型,表示旋转角度。正的角度值表示顺时针旋转,负值表示逆时针旋转。</dd> +</dl> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">在ℝ<sup>2</sup>上的笛卡尔坐标</th> + <td rowspan="2">这种变换应用于3D空间,不可用于平面空间</td> + </tr> + <tr> + <th scope="col">在ℝℙ<sup>2</sup>上的齐次坐标</th> + </tr> + <tr> + <th scope="col">在ℝ<sup>3</sup>上的笛卡尔坐标</th> + <td colspan="1"><a href="/@api/deki/files/5987/=transform-functions-rotate3d_cart.png"><img src="/@api/deki/files/5987/=transform-functions-rotate3d_cart.png?size=webview" style="height: 47px; width: 510px;"></a><math> <mfenced><mtable><mtr><mtd>1<mo>+</mo>(1<mo>-</mo>cos(<mi>a</mi>))(<msup><mi>x</mi><mn>2</mn></msup><mo>-</mo>1)</mtd><mtd><mi>z</mi><mo>·</mo>sin(<mi>a</mi>)+<mi>x</mi><mi>y</mi>(1<mo>-</mo>cos(<mi>a</mi>))</mtd><mtd><mo>-</mo><mi>y</mi><mo>·</mo>sin(<mi>a</mi>)<mo>+</mo><mi>x</mi><mi>z</mi><mo>·</mo>(1<mo>-</mo>cos(<mi>a</mi>))</mtd></mtr><mtr><mtd><mo>-</mo><mi>z</mi><mo>·</mo>sin(<mi>a</mi>)<mo>+</mo><mi>x</mi><mi>y</mi><mo>·</mo>(1<mo>-</mo>cos(<mi>a</mi>))</mtd><mtd>1+(1-cos(a))(y2-1)</mtd><mtd><mi>x</mi><mo>·</mo>sin(<mi>a</mi>)<mo>+</mo><mi>y</mi><mi>z</mi><mo>·</mo>(1<mo>-</mo>cos(<mi>a</mi>))</mtd><mtr><mtd>ysin(a) + xz(1-cos(a))</mtd><mtd>-xsin(a)+yz(1-cos(a))</mtd><mtd>1+(1-cos(a))(z2-1)</mtd><mtd>t</mtd></mtr><mtr><mtd>0</mtd><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd></mtr> </mtr></mtable></mfenced></math></td> + </tr> + <tr> + <th scope="col">在ℝℙ<sup>3</sup>上的齐次坐标</th> + <td colspan="1"><a href="/@api/deki/files/5986/=transform-functions-rotate3d_hom4.png"><img src="/@api/deki/files/5986/=transform-functions-rotate3d_hom4.png?size=webview" style="height: 61px; width: 522px;"></a></td> + </tr> + </tbody> +</table> + +<h2 id="示例">示例</h2> + +<h3 id="绕Y轴旋转">绕Y轴旋转</h3> + +<h4 id="HTML">HTML</h4> + +<pre class="brush: html notranslate"><div>Normal</div> +<div class="rotated">Rotated</div></pre> + +<h4 id="CSS">CSS</h4> + +<pre class="brush: css notranslate">body { + perspective: 800px; +} + +div { + width: 80px; + height: 80px; + background-color: skyblue; +} + +.rotated { + transform: rotate3d(0, 1, 0, 60deg); + background-color: pink; +}</pre> + +<h4 id="效果">效果</h4> + +<p>{{EmbedLiveSample("绕Y轴旋转","100%","200")}}</p> + +<h3 id="围绕自定义轴旋转">围绕自定义轴旋转</h3> + +<h4 id="HTML_2">HTML</h4> + +<pre class="brush: html notranslate"><div>Normal</div> +<div class="rotated">Rotated</div></pre> + +<h4 id="CSS_2">CSS</h4> + +<pre class="brush: css notranslate">body { + perspective: 800px; +} + +div { + width: 80px; + height: 80px; + background-color: skyblue; +} + +.rotated { + transform: rotate3d(1, 2, -1, 192deg); + background-color: pink; +}</pre> + +<h4 id="效果_2">效果</h4> + +<p>{{EmbedLiveSample("围绕自定义轴旋转","100%","200")}}</p> + +<h2 id="浏览器兼容">浏览器兼容</h2> + +<p>有关兼容性信息,请参阅<code><a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function#Browser_compatibility"><transform-function></a></code> 数据类型。</p> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{cssxref("transform")}}</li> + <li>{{cssxref("<transform-function>")}}</li> +</ul> |