HTML <map>标签的使用
2012-05-15 20:15
851 查看
在html代码中,给图像使用<map>标签,可以给图像的某个部分建立超链接,方法如下:
<img src="img.gif" usemap="map-name">
<map name="map-name">
<area shape="rect|circle|poly" coords="#" href="url">
</map>
其中,坐标coords对各个shape的解释如下:
1、shape="rect" coords="x1,y1,x2,y2" // (x1,y1)=Upper Left, (x2,y2)=Lower Right
即,当shape是矩形时,coords表示矩形左上及右下(x2, y2)的坐标
2、shape="circle" coords="x,y,r" // (x,y)=Center, r=Radius
即,当shape是圆形时,coords表示圆中心点坐标(x, y)及半径
3、shape="poly" coords="x1,y1,x2,y2,x3,y3..." // (x1,y1>=First Corner, (x2,y2)=Second Corner, ...
即,当shape是poly多边形时,coords表示多边形所有顶点的坐标(x1,y1),(x2,y2),(x3,y3)...
注意:以上所有坐标都是相对于图形img.gif左上角位置而言的
以下是一个例子:
<img src="mapimg.gif" usemap="#Face">
<map name="Face">
<area shape="rect" href="page.html" coords="140,20,280,60">
<area shape="poly" href="image.html" coords="100,100,180,80,200,140">
<area shape="circle" href="new.html" coords="80,100,60">
</map>
<img src="img.gif" usemap="map-name">
<map name="map-name">
<area shape="rect|circle|poly" coords="#" href="url">
</map>
其中,坐标coords对各个shape的解释如下:
1、shape="rect" coords="x1,y1,x2,y2" // (x1,y1)=Upper Left, (x2,y2)=Lower Right
即,当shape是矩形时,coords表示矩形左上及右下(x2, y2)的坐标
2、shape="circle" coords="x,y,r" // (x,y)=Center, r=Radius
即,当shape是圆形时,coords表示圆中心点坐标(x, y)及半径
3、shape="poly" coords="x1,y1,x2,y2,x3,y3..." // (x1,y1>=First Corner, (x2,y2)=Second Corner, ...
即,当shape是poly多边形时,coords表示多边形所有顶点的坐标(x1,y1),(x2,y2),(x3,y3)...
注意:以上所有坐标都是相对于图形img.gif左上角位置而言的
以下是一个例子:
<img src="mapimg.gif" usemap="#Face">
<map name="Face">
<area shape="rect" href="page.html" coords="140,20,280,60">
<area shape="poly" href="image.html" coords="100,100,180,80,200,140">
<area shape="circle" href="new.html" coords="80,100,60">
</map>
相关文章推荐
- HTML <area><map>标签及在实际开发中的应用
- HTML标签天天练8--<img><map><area>图像超链接
- 在HTML的<img>标签使用onblur事件
- HTML <map> 标签
- <html:optionsCollection />标签与LabelValueBean使用方法
- HTML中<meta>标签的使用
- <html:select>,<html:option>,<html:options>,<html:optionsCollection>标签使用
- (22)HTML标签详解之<img><map><area>
- HTML <map> 标签
- 关于HTML中<meta>标签的使用。
- Android UI设计之<六>使用HTML标签,实现在TextView中对部分文字进行加粗显示
- 关于使用Html <audio>标签播放视频文件的问题
- 使用<yield>标签来包含内部HTML
- 使用java正则表达式过滤HTML ,获取<body>标签中的内容解决思路
- 前端HTML<img>标签图像的属性和使用/图像img与背景background的区别
- HTML <map> 标签-创建带有可点击区域的图像映射
- html模板实现银幕滚动效果<marquee>标签使用
- <html:select>,<html:option>,<html:optionsCollection>标签使用
- 备战黑马程序员-html(<map>、<img>、列表标签)
- MyBatis中<resultMap>的<association>和<collection>标签的使用