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

时间 | <time>

<time>CSS数据类型表示以秒或毫秒表示的时间值。它用于animationtransition和其他相关属性。

语法

time由一个<number>和其后的单位组成。与所有维度一样,单位文字和数字之间没有空格。

尽管有没有单位,数字0总是表示相同的意义,但在time类型中单位不能省略。换句话说,单独的0是无效的,并不代表0s0ms

单位

s——代表以秒为单位的时间度量。例如:0s1.5s-60s

ms——表示以毫秒为单位的时间度量。例如:0ms1500ms-60000ms

sms之间的转换遵循1s= 1000ms

实例

有效值

代码语言:txt
复制
12s         正整数
-456ms      负整数
4.3ms       非整数
14mS        单位不区分大小写,但不建议大写字母。
+ 0s        零,带有前导符号+和单位
-0ms        零,带有前导符号-和单位

无效值

代码语言:javascript
复制
0           尽管<length>允许无单位的零,但在<time>这样的值是无效的。
12.0        这是一个<number>,而不是<time>,因为它缺少一个单位。
7 ms        数字和单位之间不允许有空格。

规范

Specification

Status

Comment

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

Candidate Recommendation

Normative definition of s and ms.

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

Recommendation

Informal definition of s and ms.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

4.0 (2.0)

9.0

10.5 (2.3)

(Yes)

Feature

Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

?

?

?

No support

?

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com