HTML图像映射(将某一区域作为链接)

W3school效果图:

HTML图像映射(将某一区域作为链接)_HTML


链接:https://www.w3school.com.cn/tiy/t.asp?f=html_areamap

效果解释:
点击图片上特定区域可以跳转到链接的页面,如上图,有三个部分可以点击,分别链接到对应的页面。

我的:

图片:

HTML图像映射(将某一区域作为链接)_当前页_02


图中有三个区域可以点击进行链接。但是我只做了左下角的链接。

代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<img src="4.jpg" border="0" usemap="#plantmap" />

<map name="plantmap" id="plantmap">
<area shape="rest"
coords="0,690,110,900"
href="4.jpg"
target="_self"
alt="sun"
  />
</map>
</body>
</html>

重点:
usemap的值是链接到下面的map,如通过id。
shape是设置区域的样式,矩形:rect,圆形:cric,多边形:poly。
coords是设置位置。
rect(x1,y1,x2,y2):
则该值规定矩形左上角和右下角的坐标。
cric(x,y,radius):
则该值规定圆心的坐标和半径。
poly(x1,y1,x2,y2,…,xn,yn):
则该值规定多边形各边的坐标。如果第一个坐标和最后一个坐标不一致,那么为了关闭多边形,浏览器必须添加最后一对坐标。
href:链接的图片。
target:当前页面打开(_self)或新页面打开(_blank)。