SVGTextPositioningElement: 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-Eigenschaft des SVGTextPositioningElement-Interfaces ist schreibgeschützt und beschreibt die x-Achsen-Koordinate des SVGTextElement, SVGTSpanElement oder SVGTRefElement als eine SVGAnimatedLengthList. Sie spiegelt den horizontalen Wert des Attributes x wider, das die horizontale Position der einzelnen Textglyphen im Benutzerskoordinatensystem darstellt.

Der Attributwert ist eine Liste von \<length>, \<percentage> oder \<number>. Die numerischen Werte in der SVGAnimatedLengthList.baseVal spiegeln die x-Koordinaten im Benutzerskoordinatensystem wider.

Wert

Beispiele

Angenommen, das folgende SVG:

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <text x="10" y="20">Hello</text>
  <text x="50" y="50">World</text>
</svg>

Wir können auf die berechneten Werte der x-Attribute zugreifen:

js
const texts = document.querySelectorAll("text");

console.log(texts[0].x.baseVal[0].value); // output: 10
console.log(texts[1].x.baseVal[0].value); // output: 50

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGTextPositioningElement__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