如何在链接下显示文字?
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
登录触发p显示的位置?
我是否需要使用p或其他东西?
答案 0 :(得分:18)
这很简单,只需在标签
中添加标题属性即可<a href="http://www.studyofcs.com" title="Tricks Site">Studyofcs</a>
答案 1 :(得分:14)
以下样式会在悬停时显示p
:
.login a p {display:none;}
.login a:hover p {display:block;}
&#13;
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
&#13;
或者,如果您希望包含p
的整个链接在悬停时一起显示,请使用以下内容:
.login a p {display:none;}
.login a:hover p {display:block;}
.login a:hover {display:block;}
&#13;
<div class="login">
<a href="">Login
<p>Access your profile here</p>
</a>
</div>
&#13;
答案 2 :(得分:2)
如果您正在使用引导程序,则可以使用以下命令:
<a class="login" href="" data-toogle="tooltip" title="Access your profile here">Login</a>
答案 3 :(得分:0)
简单的HTML工具提示
<a href="https://stackoverflow.com/" title="Where Developers Learn, Share, & Build Careers">stackoverflow</a>
使用Bootstrap的工具提示:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h3>Tooltip Example</h3>
<p>The data-placement attribute specifies the tooltip position.</p>
<ul class="list-inline">
<li><a href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">Top</a></li>
<li><a href="#" data-toggle="tooltip" data-placement="bottom" title="Hooray!">Bottom</a></li>
<li><a href="#" data-toggle="tooltip" data-placement="left" title="Hooray!">Left</a></li>
<li><a href="#" data-toggle="tooltip" data-placement="right" title="Hooray!">Right</a></li>
</ul>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</body>
</html>
您还可以通过Bootstrap + JQuery实现悬停工具提示:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h3>Tooltip Example</h3>
<a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
</body>
</html>