在图像上创建工具提示的建议
是否有一种替代(并且更优雅!)的方法可以在图像之上创建多个工具提示而不使用图像映射?最好寻找使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我理解你的问题,但有两件事我们不能回避。
因为#2,只能使用图像映射。但是,如果您的工具提示区域仅限于点和框,那么您可以不创建图像映射。这并不意味着图像源不必提供任何信息,因为这没有意义,它只是意味着源可以提供一个谈论图像的通用 JSON 对象。图像到达客户端后,您可以调用您编写的函数,在图像顶部创建一个不可见的
div
,并根据您收到的数据创建小的div
code> 绑定了mouseenter()
的区域。即使这样,它也离图像地图不远了。我想我想要表达的观点是,您无法摆脱将数据附加到图像并在数据到达客户端后对其进行一些处理的情况。这是因为您正在处理这样一个不受限制的图像环境,该图像可以呈现任何形状,并且您的区域可以呈现任何形状。
我不确定这是否以任何方式回答你的问题,但优雅通常来自于利用限制,在这种情况下,我们几乎无法处理任何事情。
I understand your question, but there are two few things that we cannot break from.
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 smalldiv
regions that havemouseenter()
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.