<map>:圖像映射元素
嘗試一下
屬性
此元素包括全域屬性 (en-US)。
name
-
name
屬性給映射一個名稱,以便可以引用它。該屬性必須存在,並且必須具有非空值,沒有空格字符。name
屬性的值不能等於同一文件中另一個<map>
元素的name
屬性的值。如果還指定了id
(en-US) 屬性,則兩個屬性的值必須相同。
範例
具有兩個區域的圖像映射
單擊左邊的鸚鵡可查看 JavaScript,單擊右邊的鸚鵡可查看 CSS。
HTML
html
<!-- Photo by Juliana e Mariana Amorim on Unsplash -->
<map name="primary">
<area
shape="circle"
coords="75,75,75"
href="https://developer.mozilla.org/docs/Web/JavaScript"
target="_blank"
alt="JavaScript" />
<area
shape="circle"
coords="275,75,75"
href="https://developer.mozilla.org/docs/Web/CSS"
target="_blank"
alt="CSS" />
</map>
<img
usemap="#primary"
src="parrots.jpg"
alt="350 x 150 picture of two parrots" />
結果
技術摘要
規範
Specification |
---|
HTML Standard # the-map-element |
瀏覽器相容性
BCD tables only load in the browser