<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

瀏覽器相容性

另見