我正在使用下一个简单的 html 代码 -
<html lang="en">
<head></head>
<body>
<a href="#" title="This is some information for our tooltip." class="tooltip">
<span>CSS3 Tooltip</span>
</a>
</body>
</html>
我还添加了一些 css 规则,以便在鼠标悬停在链接上时提供漂亮的工具提示
.tooltip {
display: inline;
position: relative;
}
.tooltip:hover:after{
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(title);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.tooltip:hover:before {
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
问题是,现在我得到了工具提示,还有标题的原始弹出窗口 -
有没有办法让白色工具提示消失?并且仅通过使用 css 规则?
感谢您的帮助
最佳答案
改用 data-*
属性。
.tooltip {
display: inline;
position: relative;
top: 50px;
}
.tooltip:hover:after {
background: #333;
background: rgba(0, 0, 0, .8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(data-title);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.tooltip:hover:before {
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
<a href="#" data-title="This is some information for our tooltip." class="tooltip"><span>CSS3 Tooltip</span></a>
关于html - CSS-如何防止显示原始标题信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27690547/