HTML img 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>
<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>
嘗試一下»
瀏覽器支持
所有主流瀏覽器都支持usemap 屬性。
定義和用法
usemap 屬性將圖像定義為客戶端圖像映射(圖像映射指的是帶有可點擊區域的圖像)。
usemap屬性與<map>元素的name或id屬性相關聯,以建立<img>與<map>之間的關係。
注意:只有當<img>元素不屬於<a>或<button>元素的後代時,才允許使用usemap屬性。
HTML 4.01 與HTML5之間的差異
無。
語法
<img usemap="#mapname">
屬性值
值 | 描述 |
---|---|
#mapname | 一个 hash 字符 ("#") 加上要使用的 <map> 元素的 name 或 id。 |
HTML <img>標籤