--- title: dimension slug: Web/CSS/dimension tags: - CSS - CSS数据类型 translation_of: Web/CSS/dimension --- <div>{{CSSRef}}</div> <p><strong><code><dimension></code></strong> <a href="/zh-CN/docs/Web/CSS">CSS</a> <a href="/zh-CN/docs/Web/CSS/CSS_Types">数据类型</a>是一个带有单位的{{CSSxRef("<number>")}},例如:<code>10px</code></p> <p>CSS使用度量值来描述距离 ({{CSSxRef("<length>")}}),时间({{CSSxRef("<time>")}}),频率({{CSSxRef("<frequency>")}}),分辨率({{CSSxRef("<resolution>")}})以及其他量。</p> <h2 id="格式">格式</h2> <p> <code><dimension></code> 的格式是一个{{CSSxRef("<number>")}}后紧随一个是标记符的单位,单位大小写不敏感。</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", "<dimension>")}}</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", "<dimension>")}}</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", "<dimension>")}}</td> <td>{{Spec2("CSS2.1")}}</td> <td>Defined under Numbers and Length</td> </tr> <tr> <td>{{SpecName("CSS1", "", "<dimension>")}}</td> <td>{{Spec2("CSS1")}}</td> <td>Initial definition under "length units"</td> </tr> </tbody> </table> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("css.types.dimension")}}</p>