Html 如何将样式应用于“td”标签的“title”属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10515490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to apply style to 'title' attribute of 'td' tag
提问by Jagadeesh
I have the following code with me, and would like to customize the style of the 'title' attribute. Is there any way to do it. Thanks in advance.
我有以下代码,想自定义“title”属性的样式。有什么办法可以做到。提前致谢。
<td title="Sample Title">test</td>
采纳答案by A123321
回答by BMac
This may not have been possible many years ago - but now yes you can style the Title attribute, See here. This should work in IE7+, Safari 3+, Firefox 2.0+.
多年前这可能是不可能的 - 但现在是的,您可以设置 Title 属性的样式,请参见此处。这应该适用于 IE7+、Safari 3+、Firefox 2.0+。
Some custom styling and positioning may be required to suite your own design.
可能需要一些自定义样式和定位来适应您自己的设计。
Just to make sure this link does not go dead, the suggested code in this article to style the title attribute is:
为了确保此链接不会失效,本文中用于设置 title 属性样式的建议代码是:
<div title="Tooltip text for first div"></div> <div title="Tooltip text for second div"></div>
div:before{ content:attr(title); display:none; }
div:hover::before{ width:200px; display:block; background:yellow; border:1px solid black; padding:8px; margin:25px 0 0 10px; }
div:hover{ z-index:10; position:relative; }
回答by HymanRoark
This won't style the TD but it's a quick work around that may be what you're looking for:
这不会对 TD 进行样式设置,但它可以快速解决您正在寻找的问题:
<td><a title="Sample Title">test</a></td>
回答by Curt
In short, you cannot style the title
attribute. Its up to the browser how the title is rendered when displayed.
简而言之,您无法设置该title
属性的样式。显示时如何呈现标题取决于浏览器。
However, jQuery provides javascript alternatives which should give you the solution you are after:
但是,jQuery 提供了 javascript 替代方案,它应该为您提供您所追求的解决方案:
回答by Julie in Austin
The "title" attribute is supported by the browser, typically as a tooltip. There is no standard way with CSS to format that popup.
浏览器支持“title”属性,通常作为工具提示。CSS 没有标准方法来格式化该弹出窗口。
I'd suggest that if you have a requirement for a specially formatted tooltip that you use the onmouseover() attribute and generate the popup yourself. As others have pointed out, you could use jQuery, if you want to add support for that to your code. For a lighter-weight solution than jQuery, see SkinnyTip
如果您需要特殊格式的工具提示,我建议您使用 onmouseover() 属性并自己生成弹出窗口。正如其他人指出的那样,如果您想在代码中添加对 jQuery 的支持,您可以使用 jQuery。有关比 jQuery 更轻量级的解决方案,请参阅SkinnyTip
回答by Klaus Byskov Pedersen
No. Different browsers display the title tooltip differently, and there is no way to style it using css. If you must style it, you need to look for an alternative, such as using jQuery to display custom tooltips.
不会。不同的浏览器显示标题工具提示的方式不同,并且无法使用 css 对其进行样式设置。如果必须设置样式,则需要寻找替代方法,例如使用jQuery 显示自定义工具提示。