--- title: 整型 slug: Web/CSS/integer tags: - CSS - CSS数据类型 - Reference - Web translation_of: Web/CSS/integer ---
The <integer>
CSS data type is a special type of {{cssxref("number")}} that represents a whole number, whether positive or negative. Integers can be used in numerous CSS properties, such as {{cssxref("column-count")}}, {{cssxref("counter-increment")}}, {{cssxref("grid-column")}}, {{cssxref("grid-row")}}, and {{cssxref("z-index")}}.
The <integer>
css数据类型是一种特殊的<number>类型,它表示一个整数,无论是正数还是负数。整数可以用于许多css属性,例如{{cssxref("column-count")}}, {{cssxref("counter-increment")}}, {{cssxref("grid-column")}}, {{cssxref("grid-row")}}, and {{cssxref("z-index")}}.
The <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>数据类型由一个或多个十进制数字组成,包括0到9,可以选择前面加一个+或-号。没有与整数关联的单位。
<integer>
values. Opera 12.1 supports values up to 215-1, IE up to 220-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 [-227-1; 227-1], but other values like 224-1 and 230-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.
设置动画时,<integer>数据类型的值将使用离散的完整步骤进行插值。计算过程就像是实数,浮点数一样;离散值是使用floor函数得到的。插值的速度由与动画相关联的定时函数确定。
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.
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS3 Values', '#integers', '<integer>')}} | {{Spec2('CSS3 Values')}} | No significant change. |
{{SpecName('CSS2.1', 'syndata.html#numbers', '<integer>')}} | {{Spec2('CSS2.1')}} | Explicit definition. |
{{SpecName('CSS1', '', '<integer>')}} | {{Spec2('CSS1')}} | Implicit definition. |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
basic | 1.0 | {{CompatGeckoDesktop("1.0")}} | 3.0 | {{CompatVersionUnknown}} | 1.0 (85) |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |