blob: 644a30d0ccf8f8c34a6f231b0617f4a14cfde33c (
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: translateY()
slug: Web/CSS/transform-function/translateY
translation_of: Web/CSS/transform-function/translateY()
original_slug: Web/CSS/transform-function/translateY()
---
<div>{{CSSRef}}</div>
<p><code>translateY()</code> 在页面垂直移动元素,结果是 CSS 数据类型 {{cssxref("<transform-function>")}}。</p>
<p><img src="https://mdn.mozillademos.org/files/12125/translateY.png" style="height: 195px; width: 243px;"></p>
<div class="note">
<p><strong>注意:</strong> <code>translateY(ty)</code> 对应 <code><a href="/en-US/docs/Web/CSS/transform-function/translate">translate</a>(0, ty)</code> 或<code><a href="/en-US/docs/Web/CSS/transform-function/translate3d">translate3d</a>(0, ty, 0)</code>。</p>
</div>
<h2 id="语法">语法</h2>
<pre class="notranslate"><code>/* <length-percentage> values */
transform: translateY(200px);
transform: translateY(50%);</code></pre>
<h2 id="值">值</h2>
<dl>
<dd>{{cssxref("<length>")}} 或 {{cssxref("<percentage>")}} 表示变换向量的纵坐标。百分比指的是盒子高度,盒子由属性 {{cssxref("transform-box")}} 定义。</dd>
</dl>
<table class="standard-table">
<thead>
<tr>
<th scope="col">笛卡尔坐标 ℝ<sup>2</sup></th>
<th scope="col">
<p>在ℝℙ<sup>2</sup>上的同类坐标</p>
</th>
<th scope="col">
<p>在ℝ<sup>3</sup>上的笛卡尔坐标</p>
</th>
<th scope="col">
<p>在ℝℙ<sup>3</sup>同类坐标</p>
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="1" rowspan="2">
<p>在ℝ<sup>2 </sup>上的转换不会是线性变换但是并不能代表在笛卡尔坐标系统中使用矩阵</p>
</td>
<td><math> <mfenced><mtable><mtr>1<mtd>0</mtd><mtd>0</mtd></mtr><mtr>0<mtd>1</mtd><mtd>t</mtd></mtr><mtr><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd></mtr></mtable> </mfenced> </math></td>
<td colspan="1" rowspan="2"><math> <math> <mfenced><mtable><mtr>1<mtd>0</mtd><mtd>0</mtd></mtr><mtr>0<mtd>1</mtd><mtd>t</mtd></mtr><mtr><mtd>0</mtd><mtd>0</mtd><mtd>1</mtd></mtr></mtable> </mfenced> </math></math></td>
<td colspan="1" rowspan="2"><math> <mfenced><mtable><mtr>1<mtd>0</mtd><mtd>0</mtd><mtd>0</mtd></mtr><mtr>0<mtd>1</mtd><mtd>0</mtd><mtd>t</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>[1 0 0 1 0 t]</code></td>
</tr>
</tbody>
</table>
<h3 id="语法_2">语法</h3>
<pre class="notranslate">translateY({{cssxref("<length-percentage>")}})</pre>
<h2 id="示例">示例</h2>
<h3 id="HTML">HTML</h3>
<pre class="notranslate"><code><div>Static</div>
<div class="moved">Moved</div>
<div>Static</div></code></pre>
<h3 id="CSS">CSS</h3>
<pre class="notranslate"><code>div {
width: 60px;
height: 60px;
background-color: skyblue;
}
.moved {
transform: translateY(10px);
background-color: pink;
}</code></pre>
<h3 id="结果">结果</h3>
<p>{{EmbedLiveSample("Examples", 250, 250)}}</p>
<h2 id="规范">规范</h2>
<table>
<thead>
<tr>
<th scope="col"><strong>规范</strong></th>
<th scope="col"><strong>状态</strong></th>
<th scope="col"><strong>注释</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName("CSS3 Transforms", "#funcdef-transform-translatey", "translateY()")}}</td>
<td>{{Spec2("CSS3 Transforms")}}</td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>请查看 <code><a href="/zh-CN/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>
|