CSSNumericValue: Methode toSum()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die toSum()
-Methode der CSSNumericValue
-Schnittstelle konvertiert den Wert des Objekts in ein CSSMathSum
-Objekt, um Werte in die angegebenen Einheiten zu ändern.
Syntax
js
toSum(units)
Parameter
units
-
Die Einheiten, in die konvertiert werden soll.
Rückgabewert
Ein CSSMathSum
.
Ausnahmen
TypeError
-
Wird ausgelöst, wenn ein ungültiger Typ an die Methode übergeben wurde.
Beispiele
js
let v = CSS.px("23").add(CSS.percent("4")).add(CSS.cm("3")).add(CSS.in("9"));
v.toString(); // => "calc(23px + 4% + 3cm + 9in)"
v.toSum("px", "percent").toString(); // => "calc(1000.39px + 4%)"
Spezifikationen
Specification |
---|
CSS Typed OM Level 1 # dom-cssnumericvalue-tosum |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
toSum |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
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.