area标签的coords属性是定义区域的 x 和 y 坐标。与 shape 属性配合使用,来规定形状的坐标。图像左上角的坐标是 "0,0"。区域的形状有矩形、圆形或多边形。
<img src="/Template/Test/img/ditu.png" width="571" height="260" border="0" usemap="#Map"> <map name="Map"> <area shape="rect" coords="32,92,158,127" href="/Template/Test/anli/HTML_tyzx.html" target="_blank" alt="tyzx"> <area shape="circle" coords="269,155,34" href="/Template/Test/anli/HTML_ymjc.html" target="_blank" alt="ymjc"> <area shape="poly" coords="380,82,413,78,445,100,432,142,381,125" href="/Template/Test/anli/HTML_wqc.html" target="_blank" alt="wqc"> </map>
第一个坐标是矩形的一个角的顶点坐标,另一对坐标是对角的顶点坐标,"0,0" 是图像左上角的坐标。请注意,定义矩形实际上是定义带有四个顶点的多边形的一种简化方法。
这里的 x 和 y 定义了圆心的位置("0,0" 是图像左上角的坐标),r 是以像素为单位的圆形半径。
每一对 "x,y" 坐标都定义了多边形的一个顶点。定义三角形至少需要三组坐标;高纬多边形则需要更多数量的顶点。
<area coords="值">
shape形状 | coords属性值 | 描述 |
---|---|---|
矩形(rectangle) | x1,y1,x2,y2 | 如果 shape 属性设置为 "rect",则该值规定矩形左上角和右下角的坐标。 |
圆形(circle) | x,y,radius | 如果 shape 属性设置为 "circ",则该值规定圆心的坐标和半径。 |
多边形(polygon) | x1,y1,x2,y2,..,xn,yn | 如果 shape 属性设置为 "poly",则该值规定多边形各顶点的值。如果第一个坐标和最后一个坐标不一致,那么为了关闭多边形,浏览器必须添加最后一对坐标。 |