我有一个像这样的图像映射:
<img src ="planets.gif" width="145" height="126" alt="Planets" usemap ="#planetmap" />
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun" />
<area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury" />
<area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus" />
</map>
我使用 jQuery 将跨度附加到区域,但没有机会显示区域上的任何内容。
有没有什么方法可以在区域上显示文本,例如工具提示,但无需将鼠标悬停在页面加载时,在区域上显示文本?
谢谢你的帮助。
添加跨度时,请使用以下内容:
(未测试)
jQuery('map_div').append('span').text('Mercury').css({position:'absolute', left:'10px',top:'10px',z-index:'1'})
您可能还需要将 z-index 应用于这些跨度下方的任何 div
另一种选择是设置一个具有适当边距的相对定位 div:
jQuery('map_div').append('span').text('Mercury').css({position:'relative', margin-left:'-20px',margin-top:'-20px'})
我倾向于根据上下文使用这些方法。
这是一个工作example http://jsfiddle.net/zAJvx/2/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)