<rect>
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月.
* Some parts of this feature may have varying levels of support.
<rect> は SVG の要素で、 SVG の基本図形であり、位置・幅・高さで定義される矩形を描画します。矩形は角を丸めることができます。
使用コンテキスト
属性
x-
矩形の x 座標です。 値の型: <length> | <percentage>; 既定値:
0; アニメーション: 可 y-
矩形の y 座標です。 値の型: <length> | <percentage>; 既定値:
0; アニメーション: 可 width-
矩形の幅です。 値の型:
auto| <length> | <percentage>; 既定値:auto; アニメーション: 可 height-
矩形の高さです。 値の型:
auto| <length> | <percentage>; 既定値:auto; アニメーション: 可 rx-
矩形の角の水平方向の半径。
ryが指定されていた場合は、それが既定値です。 値の型:auto| <length> | <percentage>; 既定値:auto; アニメーション: 可 ry-
矩形の角の垂直方向の半径。
rxが指定されていた場合は、それが既定値です。 値の型:auto| <length> | <percentage>; 既定値:auto; アニメーション: 可 pathLength-
矩形の周囲の長さの合計をユーザー単位で指定します。 値の型: <number>; 既定値: none; アニメーション: 可
メモ:
SVG2 以降、x, y, width, height, rx, ry は幾何プロパティです。すなわち、これらの属性はその要素の CSS プロパティとしても使用することができます。
DOM インターフェイス
この要素は SVGRectElement インターフェイスを実装しています。
例
<svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
<!-- 通常の矩形 -->
<rect width="100" height="100" />
<!-- 角丸矩形 -->
<rect x="120" width="100" height="100" rx="15" />
</svg>
仕様書
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # RectElement> |
ブラウザーの互換性
Loading…
関連情報
- SVG プレゼンテーション属性、
fillやstrokeなど - その他の SVG 基本図形:
<circle>,<ellipse>,<line>,<polygon>,<polyline>