diff options
Diffstat (limited to 'files/zh-cn/web/css/transform-function/matrix()/index.html')
-rw-r--r-- | files/zh-cn/web/css/transform-function/matrix()/index.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/files/zh-cn/web/css/transform-function/matrix()/index.html b/files/zh-cn/web/css/transform-function/matrix()/index.html new file mode 100644 index 0000000000..61a7db5124 --- /dev/null +++ b/files/zh-cn/web/css/transform-function/matrix()/index.html @@ -0,0 +1,84 @@ +--- +title: matrix() +slug: Web/CSS/transform-function/matrix() +translation_of: Web/CSS/transform-function/matrix() +--- +<p>CSS函数 <code>matrix()</code> 指定了一个由指定的 6 个值组成的 2D 变换矩阵。这种矩阵的常量值是隐含的,而不是由参数传递的;其他的参数是以列优先的顺序描述的。</p> + +<p><code>matrix(a, b, c, d, tx, ty)</code> 是 <code>matrix3d(a, b, 0, 0, c, d, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1)</code> 的简写。</p> + +<div class="note"><strong>注意:</strong> 直到 Firefox 16, Gecko 才接受对于 <strong>tx</strong> 和<strong> ty </strong>的 {{cssxref("<length>")}} 值.</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox notranslate">matrix(<em>a</em>, <em>b</em>, <em>c</em>, <em>d</em>, <em>tx</em>, <em>ty</em>) +</pre> + +<h2 id="参数值">参数值</h2> + +<dl> + <dt><em>a</em> <em>b</em> <em>c</em> <em>d</em></dt> + <dd>描述线性变换的 {{cssxref("<number>")}} 。</dd> + <dt><em>tx</em> <em>ty</em></dt> + <dd>描述如何应用这个变换的 {{cssxref("<number>")}} 。</dd> +</dl> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">ℝ<sup>2 </sup>下的<a href="https://zh.wikipedia.org/wiki/%E7%AC%9B%E5%8D%A1%E5%B0%94%E5%9D%90%E6%A0%87%E7%B3%BB">笛卡尔坐标</a></th> + <th scope="col">ℝℙ<sup>2 </sup>下<a href="https://zh.wikipedia.org/wiki/%E9%BD%90%E6%AC%A1%E5%9D%90%E6%A0%87">齐次坐标</a></th> + <th scope="col">ℝ<sup>3</sup>下的<a href="https://zh.wikipedia.org/wiki/%E7%AC%9B%E5%8D%A1%E5%B0%94%E5%9D%90%E6%A0%87%E7%B3%BB">笛卡尔坐标</a></th> + <th scope="col">ℝℙ<sup>3</sup>下的<a href="https://zh.wikipedia.org/wiki/%E9%BD%90%E6%AC%A1%E5%9D%90%E6%A0%87">齐次坐标</a></th> + </tr> + </thead> + <tbody> + <tr> + <td colspan="1" rowspan="2"><math> <mfenced> <mtable> <mtr><mtd>a</mtd><mtd>c</mtd></mtr> <mtr><mtd>b</mtd><mtd>d</mtd></mtr> </mtable> </mfenced> </math></td> + <td> + <p><math> <mfenced> <mtable> <mtr><mtd></mtd></mtr></mtable></mfenced></math><br> + a c tx<br> + b d ty<br> + 0 0 1</p> + </td> + <td colspan="1" rowspan="2"><math> <mfenced> <mtable> <mtr><mtd></mtd></mtr>a c tx</mtable></mfenced></math><br> + b d ty<br> + 0 0 1<mtr><mtd></mtd></mtr> </td> + <td colspan="1" rowspan="2"><math> <mfenced> <mtable> <mtr><mtd>a</mtd><mtd>c</mtd><mtd>0</mtd><mtd>tx</mtd></mtr><mtr><mtd>b</mtd><mtd>d</mtd><mtd>0</mtd><mtd>ty</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> + <tr> + <td><code>[a b c d tx ty]</code></td> + </tr> + </tbody> +</table> + +<p>这些值表示以下函数:</p> + +<p>matrix( scaleX(), skewY(), skewX(), scaleY(), translateX(), translateY() )</p> + +<h2 id="示例">示例</h2> + +<h3 id="HTML">HTML</h3> + +<pre class="notranslate"><div>Normal</div> +<div class="changed">Changed</div> +</pre> + +<h3 id="CSS">CSS</h3> + +<pre class="notranslate">div { + width: 80px; + height: 80px; + background-color: skyblue; +} + +.changed { + transform: matrix(1, 2, -1, 1, 80, 80); + background-color: pink; +} + +</pre> + +<h3 id="结果">结果</h3> + +<p>请看英文版案例 <a href="https://wiki.developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix#Result">https://wiki.developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix#Result</a></p> |