我的网站上有天气图(jpg),但并不表示城市。我想添加点(带索引)显示特定的城市。什么是最好的方法。我可以使用jquery吗?
答案 0 :(得分:1)
<强> HTML:强>
<div id="weathermap">
<a class="point pos1" href="/city_1" title="City One"><span class="hide">City one</span><span class="dot">.</span></a>
<a class="point pos2" href="/city_2" title="City Two"><span class="hide">City two</span><span class="dot">.</span></a>
<img src="weather.jpg" alt="Weather Map" />
</div>
<强> CSS:强>
#weathermap {
position: relative;
padding: 0;
}
.point {
position: absolute;
line-height: 16px;
}
span.hide {
display: none; // Don't show 'city one' on the map
}
span.dot {
display: block;
// This background picture is a simple marker of 16px by 16px
background: transparent url(marker.png) no-repeat scroll center center;
width: 16px;
height: 16px;
text-indent: -9999px; //Remove the dot to replace it with a marker
}
.pos1 {
top: 50px;
left: 100px;
}
.pos2 {
top: 120px;
left: 10px;
}
要添加其他城市,只需在HTML中添加另一个<a ...>
并为其指定另一个类名,例如pos3。然后,您可以将.pos3
添加到CSS代码中,并使用top
和left
值更改坐标