整型 - CSS(层叠样式表) 编辑

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.
The <integer> css数据类型是一种特殊的<number>类型,它表示一个整数,无论是正数还是负数。整数可以用于许多css属性,例如column-count, counter-increment, grid-column, grid-row, and 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,可以选择前面加一个+或-号。没有与整数关联的单位。

Note: There is no official range of valid <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.
注意:没有有效的<integer>值的正式范围。Opera12.1支持高达215-1的值,IE高达220-1的值,其他浏览器支持更高的值。在CSS3值周期中,有很多关于设置最小支持范围的讨论:2012年4月在LC阶段的最新决定是[-227-1; 227-1],,但也提出了224-1 and 230等其他值。但是,最新的规范不再指定范围。

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.
设置动画时,<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.

规范

SpecificationStatusComment
CSS Values and Units Module Level 3
<integer>
Candidate RecommendationNo significant change.
CSS Level 2 (Revision 1)
<integer>
RecommendationExplicit definition.
CSS Level 1
<integer>
RecommendationImplicit definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
basic1.01.0 (1.7 or earlier)3.0(Yes)1.0 (85)
FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
Basic support(Yes)(Yes)(Yes)(Yes)(Yes)

参考

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:121 次

字数:9074

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文