Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put border on <area>?

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;
}
like image 377
timkl Avatar asked Dec 26 '11 10:12

timkl


1 Answers

If you're willing to use Javascript, add mouseover/mouseout event listeners to the <area> elements and .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;
}
like image 124
ThinkingStiff Avatar answered Sep 21 '22 06:09

ThinkingStiff