媒體

media 屬性指定一個媒體查詢,該查詢必須匹配才能應用樣式表。

您可以將此屬性與以下 SVG 元素一起使用

示例

html
<svg viewBox="0 0 240 220" xmlns="http://www.w3.org/2000/svg">
  <style>
    rect {
      fill: black;
    }
  </style>
  <style media="all and (min-width: 600px)">
    rect {
      fill: seagreen;
    }
  </style>

  <text y="15">Resize the window to see the effect</text>
  <rect y="20" width="200" height="200" />
</svg>

用法說明

<媒體查詢列表>
預設值 all
可動畫的
<媒體查詢列表>

此值包含一個媒體查詢,該查詢需要匹配才能應用樣式表。

如果未指定,則樣式表將無條件應用。

規範

規範
可縮放向量圖形 (SVG) 2
# StyleElementMediaAttribute

瀏覽器相容性

BCD 表格僅在瀏覽器中載入