2011-12-26 10 views
5

C'è un modo per mettere un bordo intorno a un <area>?Come mettere il margine sull'area?

ho bisogno di fare questo per testare una mappa immagine, ma questo non funziona:

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

Forse questo plugin vi aiuta http: //plugins.jquery. com/project/maphilight –

+0

Il collegamento è morto. Eccone un'altra: http://davidlynch.org/projects/maphilight/docs/ – Urbycoz

risposta

4

Se siete disposti a usare Javascript, aggiungere mouseover/mouseout listener di eventi agli elementi <area> e .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; 
} 
+1

+1 Questa è una risposta molto bella! Tks. Ho imparato una nuova tecnica oggi. – techfoobar

+0

Anch'io! Grazie per l'aiuto! : D – timkl

Problemi correlati