Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

我們的志工尚未將此文章翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!

Summary

The <time> CSS data type denotes time dimensions expressed in seconds or milliseconds. They consists of a​ ​​​​​​<number> immediately followed by the unit. Like for any CSS dimension, there is no space between the unit literal and the number.

The following units may be used :

  • s which represents a time in seconds. E.g. 0s, 1.5s, -60s.
  • ms which represents a time in milliseconds. E.g. 0ms, 1500ms, -60000ms.

Conversion between s and ms follows the logical 1s = 1000ms.

Even if all units represent the same time for the value 0, the unit may not be omitted in that case as it isn't a <length>: 0 is invalid and does not represent 0s, 0ms.

Examples

These are valid time values:

12s         Positive integer
-456ms      Negative integer
4.3ms       Non-integer
14mS        The unit is case-insensitive, though capital letters are not recommended for s and ms.
+0s         Zero, with a leading + and the unit
-0ms        Zero, with a leading - and the unit (Though strange, this is an allowed value)

These are invalid time values:

0           While unitless zero is allowed for <length>, it's invalid for all other units.
12.0        This is a <number>, not a <time>, it must have a unit
7 ms        No space is allowed between the <number> and the unit

Specifications

Specification Status Comment
CSS Values and Units Module Level 3
The definition of '<time>' in that specification.
Candidate Recommendation Normatively defined s and ms
CSS Level 2 (Revision 1)
The definition of '<time>' in that specification.
Recommendation Informatively defined s and ms

Browser compatibility

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 ?

文件標籤與貢獻者

 最近更新: Sebastianz,