<view>
<view> SVG 元素定義了 SVG 文件的特定檢視。可以透過將 <view> 元素的 id 作為 URL 的目標片段來顯示特定檢視。
使用場景
| 類別 | 無 |
|---|---|
| 允許的內容 | 任意數量的以下元素,按任意順序 描述性元素 |
屬性
視口preserveAspectRatiozoomAndPan已棄用 非標準
示例
SVG
svg
<svg viewBox="0 0 300 100" width="300" height="100"
xmlns="http://www.w3.org/2000/svg">
<view id="one" viewBox="0 0 100 100" />
<circle cx="50" cy="50" r="40" fill="red" />
<view id="two" viewBox="100 0 100 100" />
<circle cx="150" cy="50" r="40" fill="green" />
<view id="three" viewBox="200 0 100 100" />
<circle cx="250" cy="50" r="40" fill="blue" />
</svg>
HTML
html
<img src="example.svg" alt="three circles" width="300" height="100" />
<br />
<img src="example.svg#three" alt="blue circle" width="100" height="100" />
結果
DOM 介面
此元素實現 SVGViewElement 介面。
規範
| 規範 |
|---|
| 可縮放向量圖形 (SVG) 2 # ViewElement |
瀏覽器相容性
BCD 表格僅在瀏覽器中載入