图像映射适合于一幅图像的某(或几)个区域点击后跳转到另一(或多)个页面的情况,见于某些网站首页等。
W3School示例:
<img src="planets.jpg" border="0" usemap="#planetmap" alt="Planets" />
<map name="planetmap" id="planetmap">
<area shape="circle" coords="180,139,14" href ="venus.html" alt="Venus" />
<area shape="circle" coords="129,161,10" href ="mercur.html" alt="Mercury" />
<area shape="rect" coords="0,0,110,260" href ="sun.html" alt="Sun" />
</map>
步骤:
1、确定一幅要做映射的图像,以及某些映射区域与形状;
2、通过map与area元素定义链接与区域的映射关系,并给map一个name与id(两个都需要,浏览器可能有差异);
3、图像通过usemap属性绑定map元素。
涉及到的3个新属性:image标签的usemap属性、area标签的shape、coords属性。