SVGEllipseElement: cy property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Thuộc tính chỉ đọc cy của giao diện SVGEllipseElement mô tả tọa độ trục y của tâm hình elip dưới dạng SVGAnimatedLength. Nó phản ánh giá trị tính toán của thuộc tính cy trên phần tử <ellipse>.

Giá trị thuộc tính là một <length>, <percentage>, hoặc <number>. Giá trị số của SVGAnimatedLength.baseVal là tọa độ y của tâm hình elip trong hệ tọa độ người dùng.

Giá trị

Một SVGAnimatedLength.

Ví dụ

Cho SVG sau:

html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
  <ellipse cx="50" cy="75" rx="30" ry="20" fill="blue" />
  <ellipse cx="25%" cy="50%" rx="10%" ry="5%" fill="red" />
</svg>

Chúng ta có thể truy cập các giá trị tính toán của thuộc tính cy:

js
const ellipses = document.querySelectorAll("ellipse");
const cyPos0 = ellipses[0].cy;
const cyPos1 = ellipses[1].cy;

console.dir(cyPos0.baseVal.value); // output: 75
console.dir(cyPos1.baseVal.value); // output: 100 (50% chiều cao viewBox, 200)

Thông số kỹ thuật

Thông số kỹ thuật
Scalable Vector Graphics (SVG) 2
# __svg__SVGEllipseElement__cy

Tương thích trình duyệt

Xem thêm