0

我的网站上有一张天气图 (jpg),但它没有标明城市。我想添加点(带索引)显示特定城市。最好的方法是什么。我可以为此使用jquery吗?

4

1 回答 1

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;
    }

要添加另一个城市,只需将另一个添加<a ...>到您的 HTML 并为其指定另一个类名,例如 pos3。然后您可以添加CSS 代码并使用和值.pos3更改坐标topleft

于 2010-01-01T11:50:43.393 回答