草案
此页面不完整。
这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
CSSMathValue
接口在
CSS Typed Object Model API
a base class for classes representing complex numeric values.
Below is a list of interfaces based on the CSSMathValue interface.
CSSMathValue.operator
Indicates the operator that the current subtype represents.
No
None.
We create an element with a
width
determined using a
calc()
function, then
console.log()
the
operator
.
<div>has width</div>
We assign a
width
with a calculation
div {
width: calc(30% - 20px);
}
We add the JavaScript
const styleMap = document.querySelector('div').computedStyleMap();
console.log( styleMap.get('width') ); // CSSMathSum {values: CSSNumericArray, operator: "sum"}
console.log( styleMap.get('width').operator ); // 'sum'
console.log( styleMap.get('width').values[1].value ); // -20
CSSMathValue.operator
returns '
sum
' because
styleMap.get('width').values[1].value );
is
-20
: adding a negative number.
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Typed OM Level 1
The definition of 'CSSMathValue' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CSSMathValue
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
operator
|
Chrome 66 | Edge 79 | Firefox No | IE No | Opera 53 | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android 9.0 |
完整支持
不支持
实验。期望将来行为有所改变。