<number> CSS data type represents a number, being either an integer or a number with a fractional component.

句法

The syntax of <number> extends the syntax of <integer> . A fractional value is represented by a . followed by one or more decimal digits, and may be appended to an integer. There is no unit associated with numbers.

插值

When animated, values of the <number> CSS data type are interpolated as real, floating-point numbers. The speed of the interpolation is determined by the timing function associated with the animation.

范例

Valid numbers

12          A raw <integer> is also a <number>.
4.01        Positive fraction
-456.8      Negative fraction
0.0         Zero
+0.0        Zero, with a leading +
-0.0        Zero, with a leading -
.60         Fractional number without a leading zero
10e3        Scientific notation
-3.4e-2     Complicated scientific notation
					

Invalid numbers

12.         Decimal points must be followed by at least one digit.
+-12.2      Only one leading +/- is allowed.
12.1.1      Only one decimal point is allowed.
					

规范

规范 状态 注释
CSS Values and Units Module Level 4
The definition of '<number>' in that specification.
编者草案 No significant change.
CSS Values and Units Module Level 3
The definition of '<number>' in that specification.
候选推荐 No significant change.
CSS Level 2 (Revision 1)
The definition of '<number>' in that specification.
推荐 Explicit definition.
CSS Level 1
The definition of '<number>' in that specification.
推荐 Implicit definition.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
<number> Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1 IE 完整支持 5 Opera 完整支持 2 Safari 完整支持 1 WebView Android 完整支持 1 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 10.1 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0
Scientific notation Chrome 完整支持 43 Edge 完整支持 12 Firefox 完整支持 29 IE 完整支持 11 Opera 完整支持 30 Safari 完整支持 10.1 WebView Android 完整支持 43 Chrome Android 完整支持 43 Firefox Android 完整支持 29 Opera Android 完整支持 30 Safari iOS 完整支持 10.3 Samsung Internet Android 完整支持 4.0

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: