<dimension>
CSS
data type
represents a
<number>
with a unit attached to it, for example
10px
.
CSS uses dimensions to specify distances (
<length>
), durations (
<time>
), frequencies (
<frequency>
), resolutions (
<resolution>
), and other quantities.
The syntax of
<dimension>
是
<number>
immediately followed by a unit which is an identifier. Unit identifiers are case insensitive.
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)
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 Values and Units Module Level 4
The definition of '<dimension>' in that specification. |
编者草案 |
添加
cap
,
ic
,
lh
,
rlh
,
vi
,
vb
|
|
CSS Values and Units Module Level 3
The definition of '<dimension>' in that specification. |
候选推荐 |
添加
ch
,
rem
,
vw
,
vw
,
vmin
,
vmax
,
Q
|
|
CSS Level 2 (Revision 1)
The definition of '<dimension>' in that specification. |
推荐 | Defined under Numbers and Length |
|
CSS Level 1
The definition of '<dimension>' in that specification. |
推荐 | Initial definition under "length units" |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| <dimension> | Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 5 | Opera 完整支持 3.5 | Safari 完整支持 1 | WebView Android 完整支持 ≤37 | Chrome Android 完整支持 18 | Firefox Android 完整支持 4 | Opera Android 完整支持 10.1 | Safari iOS 完整支持 1 | Samsung Internet Android 完整支持 1.0 |
完整支持
<length>
), durations (
<time>
), frequencies (
<frequency>
), and resolutions (
<resolution>
)
<angle-percentage>
<angle>
<basic-shape>
<blend-mode>
<custom-ident>
<dimension>
<frequency-percentage>
<frequency>
<gradient>
<image>
<integer>
<length-percentage>
<length>
<number>
<percentage>
<ratio>
<resolution>
<shape>
<string>
<time-percentage>
<time>
<transform-function>
<url>
color
flex
ident
position