在图像上创建工具提示的建议

发布于 2024-11-24 07:52:45 字数 222 浏览 1 评论 0原文

是否有一种替代(并且更优雅!)的方法可以在图像之上创建多个工具提示而不使用图像映射?最好寻找使用 jQuery 的解决方案,但不是必需的。

虽然我知道存在图像映射的解决方案,但它们看起来非常笨重且难以维护。例如,如果图像来自动态源怎么办?该来源是否还必须提供图像映射,然后有人必须事先创建该图像映射?也许我要求太多,但如果有人对此有更优雅的解决方案,我将非常感激。

谢谢你的帮助!

Is there an alternative (and more elegant!) method of creating multiple tooltips on top of an image without using image maps? Preferably looking for a solution that makes use of jQuery, but not necessary.

While I know solutions exist with image maps, they just seem so clunky and unmaintainable. For example, what if the image comes from a dynamic source? Would that source also have to provide an image map as well, which someone would then have to create beforehand? Maybe I'm asking for too much, but on the chance that someone out there has a more elegant solution to this, I'd be very grateful.

Thanks for you help!

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

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

发布评论

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

评论(1

失眠症患者 2024-12-01 07:52:45

我理解你的问题,但有两件事我们不能回避。

  1. 您的图像可能会动态加载。
  2. 工具提示区域可以是点、框或基本上任何形状(绑定区域的一组坐标),

因为#2,只能使用图像映射。但是,如果您的工具提示区域仅限于点和框,那么您可以不创建图像映射。这并不意味着图像源不必提供任何信息,因为这没有意义,它只是意味着源可以提供一个谈论图像的通用 JSON 对象。图像到达客户端后,您可以调用您编写的函数,在图像顶部创建一个不可见的 div ,并根据您收到的数据创建小的 div code> 绑定了 mouseenter() 的区域。即使这样,它也离图像地图不远了。

我想我想要表达的观点是,您无法摆脱将数据附加到图像并在数据到达客户端后对其进行一些处理的情况。这是因为您正在处理这样一个不受限制的图像环境,该图像可以呈现任何形状,并且您的区域可以呈现任何形状。

我不确定这是否以任何方式回答你的问题,但优雅通常来自于利用限制,在这种情况下,我们几乎无法处理任何事情。

I understand your question, but there are two few things that we cannot break from.

  1. Your images might be loaded dynamically
  2. Tool-tip areas can be points, boxes, or basically ANY shape (a set of coordinates that binds a region)

Because of #2, it's impossible but to use an image map. If, however, your tool-tip areas are restricted to points and boxes, then you can make do without creating an image map. This doesn't mean that the image source doesn't have to provide any information because that doesn't make sense, it just means that the source can provide a generic JSON object that talks about the image. Once the image reaches client side, you can call a function that you wrote to create an invisible div on top of your image and based on the data you've received, create small div regions that have mouseenter() bound to them. Even with this, it's not FAR from an image map.

I guess the point I'm trying to make is that you are not getting away from having to attach data to your image AND do some processing of that data once it reaches client side. This is because you're working with such an unrestricted environment of an image that can take on any shape with your regions taking on any shape.

I'm not sure if this answers your question in any way, but usually elegance comes from taking advantage of restrictions, which in this case there is practically nothing we can work with.

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