首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

数字 | <number>

<number>CSS数据类型代表一个数字,无论是整数或分数。

语法

<number>的语法扩展了<integer>的语法。小数由“ .”后跟一个或多个十进制数字表示,并可以附加到整数上。像<integer>一样,<number>不是CSS尺寸(CSS dimensions),也没有单位。

线性插值

<number>CSS数据类型的值可以在插animation中。它们作为实浮点数被插入。内插的速度由与动画相关的timing函数决定。

实例

有效值

代码语言:javascript
复制
12           一个<integer>也是一个<number>。
4.01         正分数
-456.8       负分数
0.0          零
+0.0         零,带前导符号+
-0.0         零,带前导符号- 
.60          不带前导零的小数
10e3         科学记数法
-3.4e-2      复杂的科学记数法

无效值

代码语言:javascript
复制
12.           小数点后面必须至少有一位数字。
+ -12.2       只允许一个前导+/-。
12.1.1        只允许有一个小数点。

规范

Specification

Status

Comment

CSS Values and Units Module Level 3The definition of '<number>' in that specification.

Candidate Recommendation

No significant change.

CSS Level 2 (Revision 1)The definition of '<number>' in that specification.

Recommendation

Explicit definition.

CSS Level 1The definition of '<number>' in that specification.

Recommendation

Implicit definition.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari (WebKit)

Basic support

1.0

1.0 (1.0)

5.0

(Yes)

1.0 (85)

Scientific notation

43.0

29

11

?

?

Feature

Android

Firefox Mobile (Gecko)

IE Phone

Opera Mobile

Safari Mobile

Basic support

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

Scientific notation

(Yes)

(Yes)

(Yes)

(Yes)

(Yes)

扫码关注腾讯云开发者

领取腾讯云代金券