且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

可见区域标记?

更新时间:2023-01-04 14:13:14

jQuery插件,MapHilight:



您可能会发现 jQuery插件MapHilight 感兴趣





HTML / CSS替代



我建议使用一个div,其中包含绝对链接。原因是,这将降级非常好,并显示所有选项作为链接列表。图像映射不会那么友好。

  #myImage {
position:相对; width:640px; height:100px;
background-image:url(bkg.jpg);
}
a.apples {
display:block; position:absolute;
top:0; left:0; width:100px; height:100px;
border:1px solid red;
}
a.taters {
display:block; position:absolute;
top:0; left:200px; width:25px; height:25px;
border:1px dotted orange;
}
#myImage a span {
display:none;
}

-

 < div id =myImage> 
< ul>
< li>< a href =page1.htmlclass =apples>< span>苹果< / span>< / a>< / li&
< li>< a href =page2.htmlclass =taters>< span> Taters< / span>< / a>< / li&
< / ul>
< / div>


How do I make an html < area /> visible at all times, not just on focus?

Seems it should be as simple as this:

html:

<img src="image.png" width="100" height="100" usemap="#Map" />
<map name="Map" id="Map">
<area shape="circle" coords="50,50,50" href="#" alt="circle" />
</map>

css:

area {border: 1px solid red}

No matter what I do, it seems I cannot affect the styling of an area at all, it genuinely appears immune to css. Any ideas? Also, any other examples of un-style-able tags?

jQuery Plugin, MapHilight:

You might find the jQuery plugin MapHilight to be of interest here.

HTML/CSS Alternative

I would suggest using a div, with absolute links within. The reason being, this will degrade very nicely and show all of the options as a list of links. Image maps won't be so friendly. Furthermore, this alternative will deliver the same results, with cleaner and more modern practices.

#myImage {
  position:relative; width:640px; height:100px; 
  background-image:url("bkg.jpg");
}
a.apples {
  display:block; position:absolute; 
  top:0; left:0; width:100px; height:100px;
  border:1px solid red;
}
a.taters {
  display:block; position:absolute;
  top:0; left:200px; width:25px; height:25px;
  border:1px dotted orange;
}
#myImage a span {
  display:none;
}

--

<div id="myImage">
  <ul>
    <li><a href="page1.html" class="apples"><span>Apples</span></a></li>
    <li><a href="page2.html" class="taters"><span>Taters</span></a></li>
  </ul>
</div>