HTML usemap 屬性
定義和用法
usemap
屬性定義了一個影像(或物件)作為影像對映(影像對映是帶可點選區域的影像)。
usemap
屬性與 <map>
元素的 name 或 id
屬性相關聯,並建立 <img>
和 <map>
之間的關係。
注意: 如果 <img>
元素是 <a>
或 <button>
元素的後代,則不能使用 usemap
屬性。
適用範圍
usemap
屬性可以用於以下元素
元素 | Attribute |
---|---|
<img> | usemap |
<object> | usemap |
示例
示例
一個影像地圖,帶有可點選的區域
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>
自己動手試一試 »
示例
使用影像對映的 <object> 元素
<object data="planets.gif" width="145" height="126" usemap="#planetmap"></object>
自己動手試一試 »
瀏覽器支援
usemap
屬性在每個元素上的瀏覽器支援情況如下
元素 | |||||
---|---|---|---|---|---|
img | 是 | 是 | 是 | 是 | 是 |
object | 不支援 | 是 | 是 | 不支援 | 不支援 |