在 HTML<区域>上设置背景颜色元素?区域>
有没有办法为 HTML 元素设置背景颜色?我正在创建一个图像地图,当您将鼠标悬停在地图的某些部分上时,它们会弹出工具提示,我认为如果我可以为
设置背景颜色,那会很酷(而且很方便) ;
元素,以便您可以看到它们在图像上的位置。
我尝试了背景颜色和边框,但都没有任何效果 - 元素仍然“不可见”。我假设这是因为
是一个自闭合标签,所以它实际上没有任何尺寸?但强制设置高度和宽度也没有帮助。
Is there any way to set a background color for the HTML <area>
element? I'm creating an image map where certain sections of the map will pop up a tooltip when you mouse over them, and I thought it would be cool (and convenient) if I could set a background color for the <area>
elements so you could see where they were located over the image.
I've tried both background-color and border, and neither have any effect - the <area>
elements remain "invisible." I'm assuming this is because <area>
is a self-closing tag and so it doesn't actually have any dimensions? But forcing a height and width didn't help, either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
看来不可能。
您可能想研究一下这个 jQuery 插件:
http://plugins.jquery.com/project/maphilight
这是一个示例:
http://davidlynch.org/js/maphilight/docs/demo_usa.html#
It doesn't seem possible.
You might want to look into this jQuery plugin:
http://plugins.jquery.com/project/maphilight
Here's an example:
http://davidlynch.org/js/maphilight/docs/demo_usa.html#
你可以使用
div(set postition:absolute)
代替区域u can use
div(set postition:absolute)
instead of area有两个库提供此功能。两者的工作方式都非常重要 - 检查浏览器是否支持 Canvas,如果支持,则绘制 Canvas 形状,如果不支持(即 Internet Explorer),则绘制 VML。
有一些非常好的 ImageMapster 站点上的演示。
There are two libraries that provide this feature. Both work in the same very non-trivial way - by checking if the browser supports Canvas, then if it does, drawing a Canvas shape, and if it doesn't (i.e. Internet Explorer), drawing VML.
There are some pretty good demos on the ImageMapster site.
您可以添加标题,以便当有人将鼠标悬停在其上时,它会了解它。
例子:
You can add a title so that when someone hover on it, it gets to know about it.
Example:
您可以给底层 div 一个 id,然后使用 javascript 更改 div 背景颜色。
和
You can give the underlying div an id and then using javascript to change the divs background color.
and