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 |
瀏覽器相容性
載入中…