Html 将鼠标悬停在 href 上时如何显示文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29400034/
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 make text appear when hover over a href
提问by Xplo
How would I make text appear under a link?
如何让文本出现在链接下?
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
Where the login triggers the p to show?
登录在哪里触发 p 显示?
Do I need to use the p or something else?
我需要使用 p 还是其他东西?
回答by Mohsin Shoukat
that's simple just add title attribute in tag
这很简单,只需在标签中添加标题属性
<a href="http://www.studyofcs.com" title="Tricks Site">Studyofcs</a>
回答by Nima
The following style makes the p
visible on hover:
以下样式使p
悬停时可见:
.login a p {display:none;}
.login a:hover p {display:block;}
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
Or if you want the whole link including p
inside stay visible together on hover use the following:
或者,如果您希望包括p
内部在内的整个链接在悬停时保持可见,请使用以下内容:
.login a p {display:none;}
.login a:hover p {display:block;}
.login a:hover {display:block;}
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
回答by Giannis Brandt
In case you are using bootstrap you can use the following:
如果您正在使用引导程序,您可以使用以下内容:
<a class="login" href="" data-toogle="tooltip" title="Access your profile here">Login</a>
<a class="login" href="" data-toogle="tooltip" title="Access your profile here">Login</a>