HTML area coords 属性
htmlweb developmentfront end technology更新于 2025/9/19 3:56:17
<area> 元素的 coords 坐标属性用于设置图像地图中区域的坐标。将该属性与形状属性结合使用,可以设置区域的大小和形状。
语法如下
<area coords="value>
在上述值下,您可以使用不同的参数 − 设置以下坐标。
| x1,y1,x2,y2 | 矩形左上角和右下角的坐标 (shape="rect") |
| x,y,radius | 圆心和半径的坐标 (shape="circle") |
| x1,y1,x2,y2,..,xn,yn | 多边形边缘的坐标。 |
现在让我们看一个实现 <area> 元素的 cords 属性的示例 −
示例
<!DOCTYPE html> <html> <body> <h2>Learning</h2> <p>Learn these technologies with ease....</p> <img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/> <map name = "tutorials"> <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27" href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank" /> <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial" href = "/html/index.htm" target = "_blank" /> <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial" href = "/php/index.htm" target = "_blank" /> </map> </body> </html>
输出

在上面的例子中,我们在下图中设置了地图 −
<img src = /images/usemap.gif alt = "usemap" border = "0" usemap = "#tutorials"/>
现在,我们已经为形状设置了地图及其内部区域 −
<map name = "tutorials"> <area shape = "poly" coords = "74,0,113,29,98,72,52,72,38,27" href = "/perl/index.htm" alt = "Perl Tutorial" target = "_blank" /> <area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial" href = "/html/index.htm" target = "_blank" /> <area shape = "circle" coords = "73,168,32" alt = "PHP Tutorial" href = "/php/index.htm" target = "_blank" /> </map>
在设置区域时,我们用 cords 属性设置了区域的坐标 −
<area shape = "rect" coords = "22,83,126,125" alt = "HTML Tutorial" href = "/html/index.htm" target = "_blank" />
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

