<integer> - CSS: Cascading Style Sheets 编辑
The <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
, and z-index
.
Syntax
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>
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.Interpolation
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.
Examples
Valid integers
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 -
Invalid integers
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.
Specifications
Specification | Status | Comment |
---|---|---|
CSS Values and Units Module Level 4 The definition of '<integer>' in that specification. | Editor's Draft | No significant change. |
CSS Values and Units Module Level 3 The definition of '<integer>' in that specification. | Candidate Recommendation | No significant change. |
CSS Level 2 (Revision 1) The definition of '<integer>' in that specification. | Recommendation | Explicit definition. |
CSS Level 1 The definition of '<integer>' in that specification. | Recommendation | Implicit definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论