<dimension>

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

<dimension> CSS 数据类型表示一个带有单位的<number>,例如10px

CSS 使用 dimension 来指定距离(<length>)、持续时间(<time>)、频率(<frequency>)、分辨率(<resolution>)以及其他量。

语法

<dimension> 的语法是一个<number>,紧随其后的是一个作为标识符的单位。单位标识符不区分大小写。

示例

有效 dimension

12px      12 pixels
1rem      1 rem
1.2pt     1.2 points
2200ms    2200 milliseconds
5s        5 seconds
200hz     200 Hertz
200Hz     200 Hertz (values are case insensitive)

无效 dimension

12 px       The unit must come immediately after the number.
12"px"      Units are identifiers and therefore unquoted.
3sec        The seconds unit is abbreviated "s" not "sec".

规范

规范
CSS 值和单位模块第 4 级
# dimensions

浏览器兼容性

另见