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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:45:52  来源:igfitidea点击:

How to make text appear when hover over a href

htmlcsstexthref

提问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 pvisible 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 pinside 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>