简体   繁体   English

如何显示图像地图区域的轮廓(html,javascript)?

[英]How can I show the outline of an area of a map of an image (html, javascript)?

If you take a quick look at the two links below, you'll see most people want to get rid of the outline around the area of a map on an image. 如果您快速浏览下面的两个链接,您会看到大多数人想要摆脱图像上地图区域周围的轮廓。 I see this occurs on the MAC OS X platform, exclusively. 我看到这只发生在MAC OS X平台上。

Removing outline on image map area 删除图像映射区域上的轮廓

How do I get rid of this border outline for my image map areas when clicked (OS X Chrome Only) 单击时如何摆脱图像映射区域的边框轮廓(仅限OS X Chrome)

However, what I want to do is show the outline in multiple browsers and change it's color and width. 但是,我想要做的是在多个浏览器中显示轮廓并更改它的颜色和宽度。 I tried but to avail. 我试过但是有用。 I created a style for an id. 我为id创建了一个样式。 Didn't work. 没工作。 I tried using a class and that didn't work. 我尝试使用一个类,但没有用。 I set an inline style and that didn't work, either. 我设置了内联样式,但也没有用。 And I attempted it on both the map and area tags, by the way. 顺便说一句,我在地图和区域标签上尝试了它。

As of now, I use a gif to "border" the area when clicked. 截至目前,我点击时使用gif来“边界”该区域。 But it would make things so much easier if I could take advantage of the built-in shape attribute to highlight the area clicked. 但如果我可以利用内置的shape属性来突出显示所点击的区域,那么它会让事情变得如此简单。

Thank you very much for any help. 非常感谢您的帮助。

Older versions of Internet Explorer do not respect CSS for the area outlines. 旧版本的Internet Explorer不尊重区域大纲的CSS。 You can solve this by blocking the default handing of the mousedown event. 您可以通过阻止mousedown事件的默认处理来解决此问题。 If using jquery, something like 如果使用jquery,就像

$('area').bind('mousedown',function(e) {
    e.preventDefault();
});

would take care of it for all image maps on the page. 将为页面上的所有图像映射处理它。

Also take a look at my plugin: http://www.outsharked.com/imagemapster which will let you easily handle outline (and other) effects on mouseover and click events. 另外看一下我的插件: http//www.outsharked.com/imagemapster ,它可以让你轻松处理鼠标悬停和点击事件的轮廓(和其他)效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM