Thinking about it on my way to the supermarket, you could of course also skip the entire image map idea, and make use of :hover
on the elements on top of the image (changed the divs to a-blocks). Which makes things hell of a lot simpler, no jQuery needed...
Short explanation:
.area {_x000D_
background:#fff;_x000D_
display:block;_x000D_
height:475px;_x000D_
opacity:0;_x000D_
position:absolute;_x000D_
width:320px;_x000D_
}_x000D_
#area2 {_x000D_
left:320px;_x000D_
}_x000D_
#area1:hover, #area2:hover {_x000D_
opacity:0.2;_x000D_
}
_x000D_
<a id="area1" class="area" href="#"></a>_x000D_
<a id="area2" class="area" href="#"></a>_x000D_
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Saimiri_sciureus-1_Luc_Viatour.jpg/640px-Saimiri_sciureus-1_Luc_Viatour.jpg" width="640" height="475" />
_x000D_
I just created something similar with jQuery, I don't think it can be done with CSS only.
Short explanation:
#map
is on top (absolute position) (to prevent call to mouseout
when the rollovers appear) $(document).ready(function() {_x000D_
if($('#location-map')) {_x000D_
$('#location-map area').each(function() {_x000D_
var id = $(this).attr('id');_x000D_
$(this).mouseover(function() {_x000D_
$('#overlay'+id).show();_x000D_
_x000D_
});_x000D_
_x000D_
$(this).mouseout(function() {_x000D_
var id = $(this).attr('id');_x000D_
$('#overlay'+id).hide();_x000D_
});_x000D_
_x000D_
});_x000D_
}_x000D_
});
_x000D_
body,html {_x000D_
margin:0;_x000D_
}_x000D_
#emptygif {_x000D_
position:absolute;_x000D_
z-index:200;_x000D_
}_x000D_
#overlayr1 {_x000D_
position:absolute;_x000D_
background:#fff;_x000D_
opacity:0.2;_x000D_
width:300px;_x000D_
height:160px;_x000D_
z-index:100;_x000D_
display:none;_x000D_
}_x000D_
#overlayr2 {_x000D_
position:absolute;_x000D_
background:#fff;_x000D_
opacity:0.2;_x000D_
width:300px;_x000D_
height:160px;_x000D_
top:160px;_x000D_
z-index:100;_x000D_
display:none;_x000D_
}
_x000D_
<img src="http://www.tfo.be/jobs/axa/premiumplus/img/empty.gif" width="300" height="350" border="0" usemap="#location-map" id="emptygif" />_x000D_
<div id="overlayr1"> </div>_x000D_
<div id="overlayr2"> </div>_x000D_
<img src="http://2.bp.blogspot.com/_nP6ESfPiKIw/SlOGugKqaoI/AAAAAAAAACs/6jnPl85TYDg/s1600-R/monkey300.jpg" width="300" height="350" border="0" />_x000D_
<map name="location-map" id="location-map">_x000D_
<area shape="rect" coords="0,0,300,160" href="#" id="r1" />_x000D_
<area shape="rect" coords="0,161,300,350" href="#" id="r2"/>_x000D_
</map>
_x000D_
Hope it helps..
~ Answered on 2011-12-01 15:42:37