将点添加到天气图

发布于 2024-08-16 08:38:12 字数 76 浏览 3 评论 0原文

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

I have a weather map on my website (jpg), but it does not indicate cities. I would like to add point (with an index) show particular cities. What is the best way to do that. Can I use jquery for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2024-08-23 08:38:12

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 中添加另一个 并为其指定另一个类名,就像 pos3 一样。然后,您可以将 .pos3 添加到 CSS 代码中,并使用 topleft 值更改坐标

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

To add another city, just add another <a ...> to your HTML and give it another classname, like pos3. Then you can add .pos3 to you CSS-code and change the coordinates with top and left values

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文