gpt4 book ai didi

css - 带箭头的纯 CSS 工具提示

转载 作者:行者123 更新时间:2023-11-28 16:04:14 26 4
gpt4 key购买 nike

我有这个:

span {
padding: 10px;
display: inline;
}

[title]:hover::before {
background: #333;
top: 20%;
background: rgba(0,0,0,.8);
border-radius: 5px;
color: #fff;
content: attr(title);
padding: 5px 15px;
position: absolute;
z-index: 98;
width: auto;
}
<span class="dijitButtonContents" id="saveButton" title="Save as draft"><span id="saveButton_label">Save</span></span>

我需要像这样添加一个指向箭头:

enter image description here

谁能帮助我仅使用伪元素来实现这一点?

谢谢。

最佳答案

像这样?

span {
padding: 10px;
display: inline;
}

[title] {
position: relative;
}

[title]:hover:before {
background: #333;
top: 100%;
background: rgba(0, 0, 0, .8);
border-radius: 5px;
color: #fff;
content: attr(title);
padding: 5px 15px;
position: absolute;
z-index: 98;
width: auto;
margin-top: 10px;
}

[title]:hover:after {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 10px solid #333;
content: ' ';
position: absolute;
top: 100%;
left: 50%;
}
<span class="dijitButtonContents" id="saveButton" title="Save as draft"><span id="saveButton_label">Save</span></span>

关于css - 带箭头的纯 CSS 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49365185/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com