CSS参考手册
值和单位 | Values & Units
时间 |
<time>
CSS数据类型表示以秒或毫秒表示的时间值。它用于animation
,transition
和其他相关属性。
语法
time
由一个<number>
和其后的单位组成。与所有维度一样,单位文字和数字之间没有空格。
尽管有没有单位,数字0
总是表示相同的意义,但在time
类型中,
单位不能省略。换句话说,单独的0
是无效的,并不代表0s
或0ms
。
单位
s
——代表以秒为单位的时间度量。例如:0s
,1.5s
,-60s
。
ms
——表示以毫秒为单位的时间度量。例如:0ms
,1500ms
,-60000ms
。
s
和ms
之间的转换遵循1s
= 1000ms
。
实例
有效值
12s 正整数
-456ms 负整数
4.3ms 非整数
14mS 单位不区分大小写,但不建议大写字母。
+ 0s 零,带有前导符号+和单位
-0ms 零,带有前导符号-和单位
无效值
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 |
? |
值和单位 | Values & Units相关
层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。