SVGRectElement: width 属性
SVGRectElement
接口的只读属性 width
以 SVGAnimatedLength
的形式描述了 SVG 矩形的水平尺寸。该长度以用户坐标系统中的 x 轴单位表示。其语法与 <length>
相同。
它反映了 <rect>
元素的 width
表示属性。CSS width
属性优先于 SVG width
表示属性,因此该值可能无法反映元素的实际大小。默认值为 0
。
值
一个 SVGAnimatedLength
对象。
示例
js
const rectangle = document.querySelector("rect");
const rectWidth = rectangle.width;
console.log(rectWidth.baseVal.value); // the `width` value
规范
规范 |
---|
Scalable Vector Graphics (SVG) 2 # __svg__SVGRectElement__width |
浏览器兼容性
加载中…