aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/dimension/index.html
blob: 367cd4a5d4268b0e310275eeef073a577dd53db0 (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
---
title: dimension
slug: Web/CSS/dimension
tags:
  - CSS
  - CSS数据类型
translation_of: Web/CSS/dimension
---
<div>{{CSSRef}}</div>

<p><strong><code>&lt;dimension&gt;</code></strong> <a href="/zh-CN/docs/Web/CSS">CSS</a> <a href="/zh-CN/docs/Web/CSS/CSS_Types">数据类型</a>是一个带有单位的{{CSSxRef("&lt;number&gt;")}},例如:<code>10px</code></p>

<p>CSS使用度量值来描述距离 ({{CSSxRef("&lt;length&gt;")}}),时间({{CSSxRef("&lt;time&gt;")}}),频率({{CSSxRef("&lt;frequency&gt;")}}),分辨率({{CSSxRef("&lt;resolution&gt;")}})以及其他量。</p>

<h2 id="格式">格式</h2>

<p> <code>&lt;dimension&gt;</code> 的格式是一个{{CSSxRef("&lt;number&gt;")}}后紧随一个是标记符的单位,单位大小写不敏感。</p>

<h2 id="Examples">Examples</h2>

<h3 id="合法的度量值">合法的度量值</h3>

<pre class="syntaxbox example-good">12px      12像素
1rem      1 rem
1.2pt     1.2点
2200ms    2200毫秒
200hz     200赫兹
200Hz     200赫兹(单位大小写不敏感)
</pre>

<h3 id="非法的度量值">非法的度量值</h3>

<pre class="syntaxbox example-bad">12 px       单位必须紧随数字,不能有空格
12"px"      单位是标识符,不能加引号</pre>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">状态</th>
   <th scope="col">说明</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("CSS4 Values", "#dimensions", "&lt;dimension&gt;")}}</td>
   <td>{{Spec2("CSS4 Values")}}</td>
   <td>添加 <code>cap</code>, <code>ic</code>, <code>lh</code>, <code>rlh</code>, <code>vi</code>, <code>vb</code></td>
  </tr>
  <tr>
   <td>{{SpecName("CSS3 Values", "#dimensions", "&lt;dimension&gt;")}}</td>
   <td>{{Spec2("CSS3 Values")}}</td>
   <td>添加 <code>ch</code>, <code>rem</code>, <code>vw</code>, <code>vw</code>, <code>vmin</code>,<code> vmax</code>, <code>Q</code></td>
  </tr>
  <tr>
   <td>{{SpecName("CSS2.1", "syndata.html#numbers", "&lt;dimension&gt;")}}</td>
   <td>{{Spec2("CSS2.1")}}</td>
   <td>Defined under Numbers and Length</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS1", "", "&lt;dimension&gt;")}}</td>
   <td>{{Spec2("CSS1")}}</td>
   <td>Initial definition under "length units"</td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("css.types.dimension")}}</p>