这应该工作.只需用PNG图像标签替换SPAN即可.您可能还想使用显示块而不是内嵌显示图像.
<html><head>
<style>
.overlay {
display: none;
position: absolute;
}
#map {
position: relative;
border: 1px solid black;
width: 350px;
height: 200px;
}
#station_A { top: 20px; left: 85px }
#station_B { top: 150px; left: 180px }
.hover { color: green }
</style>
</head><body>
<div id="map">
<span id="station_A" class="overlay">Highlight image here.</span>
<span id="station_B" class="overlay">Highlight image here.</span>
</div>
<p>
<span class="hover station_A">Station Alpha</span> is one example.
<span class="hover station_B">Station Beta</span> is another.
</p>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
jQuery(function() {
jQuery('.overlay').each(function(i, el) {
jQuery('.' + el.id)
.mouseenter(function() { jQuery(el).css('display', 'inline') })
.mouseleave(function() { jQuery(el).css('display', 'none') });
});
});
</script>
</body></html>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9156 次 |
最近记录: |