CSSMathValue: operator-Eigenschaft

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Die schreibgeschützte Eigenschaft CSSMathValue.operator des CSSMathValue-Interfaces gibt den Operator an, den der aktuelle Subtyp darstellt. Wenn zum Beispiel der aktuelle CSSMathValue-Subtyp CSSMathSum ist, wird diese Eigenschaft die Zeichenkette "sum" zurückgeben.

Wert

Ein String.

Interface Wert
CSSMathSum "sum"
CSSMathProduct "product"
CSSMathMin "min"
CSSMathMax "max"
CSSMathClamp "clamp"
CSSMathNegate "negate"
CSSMathInvert "invert"

Beispiele

Wir erstellen ein Element mit einer width, die mit einer calc()-Funktion bestimmt wird, und verwenden dann console.log(), um den operator auszugeben.

html
<div>My width has a <code>calc()</code> function</div>

Wir weisen eine width mit einer Berechnung zu.

css
div {
  width: calc(50% - 0.5vw);
}

Wir fügen das JavaScript hinzu.

js
const styleMap = document.querySelector("div").computedStyleMap();

console.log(styleMap.get("width")); // CSSMathSum {values: CSSNumericArray, operator: "sum"}
console.log(styleMap.get("width").values); // CSSNumericArray {0: CSSUnitValue, 1: CSSMathNegate, length: 2}
console.log(styleMap.get("width").operator); // 'sum'
console.log(styleMap.get("width").values[1].operator); // 'negate'

Der CSSMathValue.operator gibt sum für die Gleichung und negate für den Operator des zweiten Wertes zurück.

Spezifikationen

Specification
CSS Typed OM Level 1
# dom-cssmathvalue-operator

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
operator

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.