SVGUseElement: height-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 height-Eigenschaft der SVGUseElement-Schnittstelle beschreibt die Höhe des referenzierten Elements als ein SVGAnimatedLength. Es spiegelt den berechneten Wert des height-Attributs auf dem <use>-Element wider.

Der Attributwert ist eine \<length>, \<percentage> oder \<number>. Der numerische Wert des SVGAnimatedLength.baseVal ist die Höhe des referenzierten Elements im Benutzerskoordinatensystem.

Wert

Beispiele

Für das folgende SVG:

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <circle id="circle1" cx="50" cy="50" r="40" fill="blue" />
    <circle id="circle2" cx="50" cy="50" r="40" fill="red" />
  </defs>
  <use x="50%" y="50%" href="#circle1" height="50" />
  <use x="25%" y="50%" href="#circle2" height="100" />
</svg>

können wir die berechneten Werte der height-Attribute abrufen:

js
const uses = document.querySelectorAll("use");
const heightUse1 = uses[0].height;
const heightUse2 = uses[1].height;

console.log(heightUse1.baseVal.value); // output: 50
console.log(heightUse2.baseVal.value); // output: 100

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGUseElement__height

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
height

Legend

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

Full support
Full support

Siehe auch