當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


HTML <img> usemap屬性用法及代碼示例

<img> usemap屬性用於將圖像指定為客戶端image-map。 image-map是可單擊的圖像區域。 usemap屬性用於在圖像和Map之間創建關係。

用法:

<img usemap="#mapname">

屬性值:


  • mapname:它用於保存包含哈希(#)字符的Map名稱。

例:

<!DOCTYPE html>  
<html>  
  
<head>  
    <title>HTML img usemap Attribute</title>  
      
    <style>  
        body {  
            text-align:center;  
        }  
          
        h1 {  
            color:green;  
        }  
    </style>  
</head>  
  
<body>  
    <h1>GeeksforGeeks</h1> 
      
    <h2>HTML <img> usemap Attribute</h2> 
  
    <img src"https://media.geeksforgeeks.org/wp-content/uploads/20190227165729/area11.png"
        alt="" width="300" height="119" usemap="#shapemap" />  
  
    <map name="shapemap">  
          
        <!-- area tag contained image. -->
        <area shape="poly" coords="59, 31, 28, 83, 91, 83" href= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165802/area2.png"
            alt="Triangle">  
          
        <area shape="circle" coords="155, 56, 26" href= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190227165934/area3.png"
            alt="Circle">  
          
        <area shape="rect" coords="224, 30, 276, 82" href= 
"https://media.geeksforgeeks.org/wp-content/uploads/20190227170021/area4.png"
            alt="Square">  
    </map>  
</body>  
  
</html> 

輸出:

支持的瀏覽器:下麵列出了HTML <img> usemap屬性支持的瀏覽器:

  • 穀歌瀏覽器
  • IE瀏覽器
  • Firefox
  • Safari
  • Opera


相關用法


注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 HTML | <img> usemap Attribute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。