SVGCircleElement: cx 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

SVGCircleElement 介面的只讀屬性 cx 反映了 <circle> 元素的 cx 屬性,並由此定義了圓心的 x 座標。

如果未指定,則效果如同將值設定為 0

一個 SVGAnimatedLength 物件,表示圓心的 x 座標。

示例

SVG

html
<svg
  xmlns="http://www.w3.org/2000/svg"
  viewBox="0 0 100 100"
  width="200"
  height="200">
  <circle cx="50" cy="50" r="50" fill="gold" id="circle" />
</svg>

JavaScript

js
const circle = document.getElementById("circle");
console.log(circle.cx);

規範

規範
Scalable Vector Graphics (SVG) 2
# __svg__SVGCircleElement__cx

瀏覽器相容性

另見