How to place the border by region?

Is there any way to place the border around <area>?

I need to do this to test imagemap, but this does not work:

area {
    outline: 1px solid red;
    border: 1px solid red;
}
+5
source share
1 answer

If you want to use Javascript, add mouseover/mouseoutevent listeners to <area>and elements .focus()/.blur().

Demo: http://jsfiddle.net/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.com/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;
}
+4
source

All Articles