SVGSVGElement: height 屬性
SVGSVGElement 介面的只讀屬性 height 以 SVGAnimatedLength 的形式描述元素的垂直尺寸。它反映了 <svg> 元素的 height 屬性,但這可能不是 SVG 的渲染高度。
CSS height 屬性優先於 <svg> 元素的 height 屬性,因此該值可能無法反映元素的顯示外觀。如果同時省略了 viewBox 和 height 屬性,則 height 屬性會反映實際高度。
值
一個 SVGAnimatedLength 物件。
示例
js
const svg = document.querySelector("svg");
const verticalSize = svg.height;
console.dir(verticalSize.baseVal.value); // the `height` value
規範
| 規範 |
|---|
| Scalable Vector Graphics (SVG) 2 # __svg__SVGSVGElement__height |
瀏覽器相容性
載入中…