HTML: <area> coords 属性

由网友 大卫 发布 阅读 5

HTML: <area> coords 属性

coords 属性指定图像地图区域的 x 和 y 坐标。coords 属性与 shape 属性配合使用,以指定区域的大小,形状和位置。 提示: 图像区域左上角的坐标为0,0

 HTML <area> 标签

在线示例

带有可点击区域的图像映射:

<!DOCTYPE html>
<html>
<title>HTML:<area> coords 属性 - 大卫编程网 div.cn</title>
<body>
<p>单击太阳或其中一个行星以近距离观察它</p>
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
   <map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="/tags/sun.html" alt="Sun">
  <area shape="circle" coords="90,58,3" href="/tags/mercur.html" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="/tags/venus.html" alt="Venus">
  </map>  
</body>
</html>
测试看看 ‹/›

浏览器兼容性

IEFirefoxOperaChromeSafari

所有主流浏览器都支持 coords 属性。

定义和用法

coords 属性指定图像地图区域的 x 和 y 坐标。

coords 属性与  shape 属性配合使用,以指定区域的大小,形状和位置。

提示: 图像区域左上角的坐标为0,0。

HTML 4.01 与 HTML5之间的差异

没有.

语法

<area coords="value">

属性值

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

 HTML <area> 标签

HTML: <area> download 属性 HTML: <area> href 属性