关于HTML图片如何设置热区

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39071593/article/details/83043396

最近在学习HTML,老师布置了一些作业,我以为HTML都很简单,但作业要求里出现了“设置热区链接”,我翻遍课本都没有提及,我就上网查资料,发现deamweaer可以不用代码设置,特别是对于不规则热区链接在此),但我用的是HBuilder,而且我没有耐性去学deamweaer怎么设置图片热区,所以我选择以敲代码的形式完成作业。

这个图片是钓鱼图:
12313213132
要求:
1.插入网页图片,并设置热区链接;
2.分别在鱼,月亮及门FISH上建立连接;

首先,img标签中usemap属性与map元素的name或id属性相关联,以建立img与map之间的关系。

<img src="img/6.jpg" usemap="#fishing">
<map name="fishing" id="fishing">

接着设置蓝色鱼热区

在这里插入图片描述

<area shape="circle" coords="137,204,35" href="other/fish.html"/>

属性解释
shape=“circle” //为热区的形状当前为圆形还有其他形状,比如poly多边形(不规则)、rect矩形
coords=“x,y,R” //coords的值分别圆形的xy位置和半径。
href=“other/fish.html” //点击热区跳到其他页面

对于矩形,作业要求把门设置为热区
在这里插入图片描述

<area shape="rect" coords="260,65,340,150" href="other/door.html"/>

如上图中标记xy数值coords="x0,y0,x1,y1"里的值分别为矩形对角的xy值

最后对于不规则图形poly
在这里插入图片描述
coords的值要一个个点设置,如coords="x0,y0,x1,y1,x2,y2,x3,y3,x4,y4…"就是很麻烦,有deamweaer推荐用deamweaerdeamweaer教程链接

本人作业完整代码如下

<body>
	<img src="img/6.jpg" usemap="#fishing">
	<map name="fishing" id="fishing">
	<area shape="circle" coords="137,204,35" href="other/fish.html"/>
	<area shape="circle" coords="180,104,20" href="other/moon.html"/>
	<area shape="rect" coords="260,65,340,150" href="other/door.html"/>
</body>

一个小小彩蛋那条蓝色鱼的超链接为
在这里插入图片描述

烤鱼一条

猜你喜欢

转载自blog.csdn.net/qq_39071593/article/details/83043396