SVGRectElement: width-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Die schreibgeschützte width-Eigenschaft der SVGRectElement-Schnittstelle beschreibt die horizontale Größe eines SVG-Rechtecks als SVGAnimatedLength. Die Länge wird in Einheiten des Benutzerkoordinatensystems entlang der x-Achse angegeben. Ihre Syntax entspricht der von <length>.

Sie spiegelt das Präsentationsattribut <rect> des Elements width wider. Die CSS-width-Eigenschaft hat Vorrang vor dem Präsentationsattribut width des SVG, sodass der Wert möglicherweise nicht die tatsächliche Größe des Elements widerspiegelt. Der Standardwert ist 0.

Wert

Beispiel

js
const rectangle = document.querySelector("rect");
const rectWidth = rectangle.width;
console.log(rectWidth.baseVal.value); // the `width` value

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGRectElement__width

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
width

Legend

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

Full support
Full support

Siehe auch