SVGPreserveAspectRatio:meetOrSlice 屬性

Baseline 已廣泛支援

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

meetOrSliceSVGPreserveAspectRatio 介面的一個只讀屬性,它反映了該介面中 SVG_MEETORSLICE_* 常量所指定的 meet-or-slice 值的型別。

以下之一:

  • SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN (0)
  • SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET (1)
  • SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE (2)

示例

訪問 meetOrSlice 屬性

html
<svg
  xmlns="http://www.w3.org/2000/svg"
  width="400"
  height="200"
  preserveAspectRatio="xMidYMid slice">
  <circle cx="100" cy="100" r="50" fill="blue" />
</svg>
js
const svgElement = document.querySelector("svg");

// Access the meetOrSlice property
console.log(svgElement.preserveAspectRatio.baseVal.meetOrSlice); // Output: 2 (SVG_MEETORSLICE_SLICE)

規範

規範
Scalable Vector Graphics (SVG) 2
# __svg__SVGPreserveAspectRatio__meetOrSlice

瀏覽器相容性