Html 添加没有 javascript 的悬停文本,就像我们悬停在用户的声誉上一样
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11022843/
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
Add hover text without javascript like we hover on a user's reputation
提问by Ash
In stackoverflow, when we hover on a user's reputation we see a text. I have seen this at many places and the source code tells me that it can be done without js. And i tried and got only this-
在 stackoverflow 中,当我们将鼠标悬停在用户的声誉上时,我们会看到一个文本。我在很多地方都看到过这个,源代码告诉我它可以在没有js的情况下完成。我试过只得到这个-
<div="text">hover me</div>
回答by gcochard
Use the title
attribute, for example:
使用title
属性,例如:
<div title="them's hoverin' words">hover me</div>
or:
或者:
<span title="them's hoverin' words">hover me</span>
回答by Slavomir
The title attribute also works well with other html elements, for example a link...
title 属性也适用于其他 html 元素,例如链接...
<a title="hover text" ng-href="{{getUrl()}}"> download link
</a>
回答by Harry Bosh
Often i reach for the abbreviation html tag in this situation.
在这种情况下,我经常使用缩写 html 标签。
<abbr title="Hover">Text</abbr>
<abbr title="Hover">Text</abbr>
回答by Abk
You're looking for tooltip
您正在寻找工具提示
For the basic tooltip, you want:
对于基本工具提示,您需要:
<div title="This is my tooltip">
For a fancier javascript version, you can look into:
对于更高级的 javascript 版本,您可以查看:
http://www.designer-daily.com/jquery-prototype-mootool-tooltips-12632
http://www.designer-daily.com/jquery-prototype-mootool-tooltips-12632
The above link gives you 12 options for tooltips.
上面的链接为您提供了 12 个工具提示选项。