我正在使用CSS制作工具提示。现在使用以下html代码
<div title="This is some information for our tooltip." class="progress3">
</div>
和以下CSS
.progress3{
display: inline;
position: relative;
}
.progress3: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;
content: attr(title);
}
.progress3:hover:before{
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
现在,它可以工作了,当我将鼠标悬停在它上面时,会显示工具提示,但同时也显示了标题...如何删除下图中橙色圆圈所示的内容。
只需不通过title
属性添加内容,即可将其更改为data-tooltip
。
.progress3:hover:after {
content: attr(data-tooltip);
}
您可以使用JS / jQuery,但是考虑到您所采用的方法,在保留功能的同时无法隐藏/删除它,因为那样您就无法通过CSS添加任何内容。
的HTML
<div data-tooltip="This is some information for our tooltip." class="progress3">
</div>
的CSS
.progress3 {
position: relative;
width: 100px;
height: 100px;
background: red;
}
.progress3:hover:after {
background: #333;
background: rgba(0,0,0,.8);
border-radius: 5px;
bottom: 26px;
color: #fff;
content: attr(data-tooltip);
left: 20%;
padding: 5px 15px;
position: absolute;
z-index: 98;
width: 220px;
}
.progress3:hover:before {
border: solid;
border-color: #333 transparent;
border-width: 6px 6px 0 6px;
bottom: 20px;
content: "";
left: 50%;
position: absolute;
z-index: 99;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句