图片的热点区域

来源:互联网 发布:mysql count限制 编辑:程序博客网 时间:2024/05/18 12:01

在做前端页面的过程中,图片的热点区域链接是我们经常遇到的,最方便的是通过DreameWeaver编辑器进行拖拽绘制热点区域,

热点区域部分的代码也会自动生成,但是这样操作虽然方便,另个一方面也削弱了我们的前端技能,以至于离开了DW工具就不知道

具体代码怎么编写了。下面我来具体说一下热点区域的坐标问题,个人理解,仅供参考:

图片的热点区域的坐标点:是以图片的左上角为坐标点,矩形的左上角坐标x1,y1和矩形的右下角坐标x2,y2来具体确定位置和大小。x1代表距离图片左上角x轴距离为x1,y1代表

距离图片左上角y轴的距离为y1;x2,y2同理。

如果是圆形的话的,则坐标分别为圆心和半径

<img src="img/spir.png" usemap="myMap"/><map id="myMap" name="myMap"><area href="maxHeight.html" shape="rect" alt="first" coords="x1,y1,x2,y2"/></map>

举例如下:

<div class="test"><img src="img/spir.png" usemap="myMap"/><map id="myMap" name="myMap"><area href="maxHeight.html" shape="rect" alt="first" coords="0,0,28,28"/><area href="maxHeight.html" shape="rect" alt="second" coords="0,28,28,56"/><area href="maxHeight.html" shape="rect" alt="third" coords="0,56,28,84"/><area href="maxHeight.html" shape="rect" alt="forth" coords="0,84,28,112"/></map></div><script type="text/javascript">$(function(){$('#myMap area').hover(function(){var idx=$(this).index();console.log($(this).attr('alt'))});});</script>