最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to put border on <area>? - Stack Overflow

programmeradmin2浏览0评论

Is there a way to put a border around an <area> element?

I need to do this for testing an imagemap, but this doesn't work:

area {
    outline: 1px solid red;
    border: 1px solid red;
}

Is there a way to put a border around an <area> element?

I need to do this for testing an imagemap, but this doesn't work:

area {
    outline: 1px solid red;
    border: 1px solid red;
}
Share Improve this question edited Aug 2, 2021 at 18:43 TylerH 21.1k77 gold badges79 silver badges112 bronze badges asked Dec 26, 2011 at 10:29 timkltimkl 3,33912 gold badges59 silver badges71 bronze badges 2
  • Maybe this plugin helps you plugins.jquery./project/maphilight – Sergey Ratnikov Commented Dec 26, 2011 at 10:33
  • That link's dead. Here's another: davidlynch/projects/maphilight/docs – Urbycoz Commented Oct 28, 2013 at 14:22
Add a ment  | 

1 Answer 1

Reset to default 8

If you're willing to use Javascript, add mouseover/mouseout event listeners to the <area> elements and .focus()/.blur().

Demo: http://jsfiddle/ThinkingStiff/Lwnf3/

Script:

var areas = document.getElementsByTagName( 'area' );
for( var index = 0; index < areas.length; index++ ) {    
    areas[index].addEventListener( 'mouseover', function () {this.focus();}, false );
    areas[index].addEventListener( 'mouseout', function () {this.blur();}, false );
};

HTML:

<img id="map" src="http://thinkingstiff./images/matt.jpg" usemap="#map"/>
<map name="map">
    <area shape="circle" coords="50,50,50" href="#" />
    <area shape="circle" coords="100,100,50" href="#" />
</map>

CSS:

#map {
    height: 245px;
    width: 180px;
}
发布评论

评论列表(0)

  1. 暂无评论