<dimension>
CSS 数据类型是一个带有单位的<number>
,例如:10px
CSS使用度量值来描述距离 (<length>
),时间(<time>
),频率(<frequency>
),分辨率(<resolution>
)以及其他量。
格式
<dimension>
的格式是一个<number>
后紧随一个是标记符的单位,单位大小写不敏感。
Examples
合法的度量值
12px 12像素 1rem 1 rem 1.2pt 1.2点 2200ms 2200毫秒 200hz 200赫兹 200Hz 200赫兹(单位大小写不敏感)
非法的度量值
12 px 单位必须紧随数字,不能有空格 12"px" 单位是标识符,不能加引号
规范
Specification | 状态 | 说明 |
---|---|---|
CSS Values and Units Module Level 4 <dimension> |
Editor's Draft | 添加 cap , ic , lh , rlh , vi , vb |
CSS Values and Units Module Level 3 <dimension> |
Candidate Recommendation | 添加 ch , rem , vw , vw , vmin , vmax , Q |
CSS Level 2 (Revision 1) <dimension> |
Recommendation | Defined under Numbers and Length |
CSS Level 1 <dimension> |
Recommendation | Initial definition under "length units" |
浏览器兼容性
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.