SVGSVGElement: x-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 x-schreibgeschützte Eigenschaft der SVGSVGElement-Schnittstelle beschreibt die horizontale Koordinate der Position dieses SVG als SVGAnimatedLength. Wenn ein <svg> in ein anderes <svg> verschachtelt ist, ist die horizontale Koordinate eine Länge im Benutzerkoordinatensystem, die die angegebene Entfernung vom Ursprung des Benutzerkoordinatensystems entlang der x-Achse darstellt. Die Syntax entspricht dabei der für <length>.

Sie entspricht dem geometrischen Attribut x des <svg>-Elements. Der Standardwert ist 0. Das x-Attribut hat keine Auswirkung auf äußere <svg>-Elemente, nur auf verschachtelte. Die CSS-Eigenschaft x hat Vorrang vor dem x-Attribut des <svg>-Elements, daher könnte der Wert das Erscheinungsbild des Elements nicht widerspiegeln.

Wert

Beispiel

js
const svg = document.querySelector("svg");
const leftPosition = svg.x;
console.dir(leftPosition.baseVal.value); // the `x` value

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGSVGElement__x

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
x

Legend

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

Full support
Full support

Siehe auch