このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

SVGRectElement: x プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

xSVGRectElement インターフェイスの読み取り専用のプロパティで、 SVG 矩形の位置の水平座標を SVGAnimatedLength として表します。 <coordinate> は、ユーザー座標系で原点からの x 軸方向の距離です。構文は、 <length> と同じです。

これは、<rect> 要素の幾何属性値 x を反映します。CSS のプロパティ x が、SVG の幾何属性 x よりも優先されるため、この値は要素の外観を反映しない場合があります。既定値は 0 です。

SVGAnimatedLength です。

js
const rectangle = document.querySelector("rect");
const leftPosition = rectangle.x;
console.log(leftPosition.baseVal.value); // `x` の値

仕様書

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGRectElement__x

ブラウザーの互換性

関連情報