HTMLSourceElement: sizes 屬性

Baseline 已廣泛支援

此特性已得到良好確立,可跨多種裝置和瀏覽器版本使用。自 2017 年 3 月起,所有瀏覽器均支援此特性。

HTMLSourceElement 介面的 sizes 屬性是一個字串,表示一系列尺寸,用於指定資源在不同斷點下的應用尺寸。

它反映了 <source> 元素的 sizes 屬性。

字串。

示例

html
<source
  id="el"
  src="mediumVideo.mov"
  type="video/quicktime"
  sizes="(50em <= width <= 60px) 50em,
         (30em <= width < 50em) 30em" />
js
const el = document.getElementById("el");
console.log(el.sizes); // Output: "(50em <= width <= 60px) 50em, (30em <= width < 50em) 30em"
el.sizes = "(50em <= width <= 60px) 100em, (30em <= width < 50em) 60em"; // Updates the sizes value

規範

規範
HTML
# dom-source-sizes

瀏覽器相容性

另見