html 图像映射(一个图像多个连接)

以前就见过那种导航地图,点击地图的不同省份分别跳到不同的连接,现在用html实现一下,简单的。

图像映射是指一个图像可以建立多个连接,就是在图像上面定义多个区域,每个区域连接到不同的地址。

效果如图:(可以直接分别点击四个人物头像试试!)


点击索隆,跳到索隆。


代码如下:

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  2. <html>  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
  5. <title>Insert title here</title>  
  6. <script type="text/javascript">  
  7. </script>  
  8. </head>  
  9. <body>  
  10.     <img src="images/haizeiwang.jpg" usemap="#haizeiwang">  
  11.     <map name="haizeiwang">  
  12.         <!-- 娜美 --><area shape="rect" coords="360,60,500,400" href="http://b.hiphotos.bdimg.com/album/s%3D550%3Bq%3D90%3Bc%3Dxiangce%2C100%2C100/sign=d74caf65b4003af349badc650511b761/d439b6003af33a8708cf4f76c45c10385343b538.jpg?referer=d74e5572bb389b5061e8d462f3d6&x=.jpg" target="_blank">  
  13.         <!-- 乔巴 --><area shape="rect" coords="250,330,360,500" href="http://g.hiphotos.bdimg.com/album/s%3D550%3Bq%3D90%3Bc%3Dxiangce%2C100%2C100/sign=24bd57a9e2fe9925cf0c695504932fe2/2cf5e0fe9925bc3142f44ef45cdf8db1cb137034.jpg?referer=d7a90a9339c79f3dd6f6d000b0ea&x=.jpg" target="_blank">  
  14.         <!-- 山治 --><area shape="circle" coords="230,230,100" href="http://e.hiphotos.bdimg.com/album/s%3D550%3Bq%3D90%3Bc%3Dxiangce%2C100%2C100/sign=5e8ee94fb27eca80160539e2a118e6e0/9213b07eca806538e048eb7f95dda144ad348238.jpg?referer=4b70b4479f16fdfa817bf2deeed6&x=.jpg" target="_blank">  
  15.         <!-- 索隆 --><area shape="poly" coords="130,20,200,50,160,150,60,200,50,100,100,70" href="http://g.hiphotos.bdimg.com/album/s%3D550%3Bq%3D90%3Bc%3Dxiangce%2C100%2C100/sign=af1dc8ebd2a20cf44290feda46323a0b/b3b7d0a20cf431ad3d700c554936acaf2edd9838.jpg?referer=ccb657a9e2fe9925921b5d60d8d6&x=.jpg" target="_blank">  
  16.     </map>  
  17.     <!--   
  18.         shape : 有几个选择:rect : 矩形,coords对应的坐标为左上角和右下角。  
  19.                            circle:圆,coords对应的是圆心(x,y),和半径r。  
  20.                            poly:   多边形,coords对应的是每个点的坐标。  
  21.         coords:坐标,根据shape的值去定义。  
  22.         href:链接。  
  23.      -->  
  24. </body>  
  25. </html>  

HTML <map> 设置图热点

需要在一张图片中,设置一个区域为热点就用到了<map>

定义一个客户端图像映射。图像映射(image-map)指带有可点击区域的一幅图像。

复制代码
<img src="planets.jpg" border="0" usemap="#planetmap" alt="Planets" border="0" />

<map name="planetmap" id="planetmap">
  <area shape="circle" coords="180,139,14" href ="venus.html" style="cursor: pointer" alt="Venus" />


  <area shape="circle" coords="129,161,10" href ="mercur.html" alt="Mercury" /> 


  <area shape="rect" coords="0,0,110,260" href ="sun.html" alt="Sun" /> 


</map>


所有主流浏览器都支持 <map> 标签。

提示和注释:

注释:area 元素永远嵌套在 map 元素内部。area 元素可定义图像映射中的区域。

注释:<img>中的 usemap 属性可引用 <map> 中的 id 或 name 属性(取决于浏览器),所以我们应同时向 <map> 添加 id 和 name 属性。

语法

<a coords="value">

属性值

描述
x1,y1,x2,y2如果 shape 属性设置为 "rect",则该值规定矩形左上角和右下角的坐标。
x,y,radius如果 shape 属性设置为 "circ",则该值规定圆心的坐标和半径。
x1,y1,x2,y2,..,xn,yn如果 shape 属性设置为 "poly",则该值规定多边形各边的坐标。如果第一个坐标和最后一个坐标不一致,那么为了关闭多边形,浏览器必须添加最后一对坐标。
复制代码

 



  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值