<integer>
CSS
data type
is a special type of
<number>
that represents a whole number, whether positive or negative. Integers can be used in numerous CSS properties, such as
column-count
,
counter-increment
,
grid-column
,
grid-row
,和
z-index
.
<integer>
data type consists of one or several decimal digits, 0 through 9 inclusive, optionally preceded by a single
+
or
-
sign. There is no unit associated with integers.
<integer>
values. Opera 12.1 supports values up to 2
15
-1, IE up to 2
20
-1, and other browsers even higher. During the CSS3 Values cycle there was a lot of discussion about setting a minimum range to support: the latest decision,
in April 2012 during the LC phase
, was [-2
27
-1; 2
27
-1], but other values like 2
24
-1 and 2
30
-1
were also proposed
. However, the latest spec doesn't specify a range anymore.
When animated, values of the
<integer>
data type are interpolated using discrete, whole steps. The calculation is done as if they were real, floating-point numbers; the discrete value is obtained using the
floor function
. The speed of the interpolation is determined by the
timing function
associated with the animation.
12 Positive integer (without a leading + sign) +123 Positive integer (with a leading + sign) -456 Negative integer 0 Zero +0 Zero, with a leading + -0 Zero, with a leading -
12.0 This is a <number>, not an <integer>, though it represents an integer. 12. Decimal points are not allowed. +---12 Only one leading +/- is allowed. ten Letters are not allowed. _5 Special characters are not allowed. \35 Escaped Unicode characters are not allowed, even if they are an integer (here: 5). \4E94 Non-arabic numerals are not allowed, even when escaped (here: the Japanese 5, 五). 3e4 Scientific notation is not allowed.
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Values and Units Module Level 4
The definition of '<integer>' in that specification. |
编者草案 | No significant change. |
|
CSS Values and Units Module Level 3
The definition of '<integer>' in that specification. |
候选推荐 | No significant change. |
|
CSS Level 2 (Revision 1)
The definition of '<integer>' in that specification. |
推荐 | Explicit definition. |
|
CSS Level 1
The definition of '<integer>' in that specification. |
推荐 | Implicit definition. |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
<integer>
|
Chrome 完整支持 1 | Edge 完整支持 12 | Firefox 完整支持 1 | IE 完整支持 3 | 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 |
完整支持
<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