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 |
浏览器兼容性
加载中…