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. Zum Beispiel, wenn der aktuelle CSSMathValue-Subtyp CSSMathSum ist, wird diese Eigenschaft den String "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 durch eine 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' Die CSSMathValue.operator-Eigenschaft gibt sum für die Gleichung und negate für den Operator auf dem zweiten Wert zurück.
Spezifikationen
| Specification |
|---|
| CSS Typed OM Level 1> # dom-cssmathvalue-operator> |