javascript - 无法为工具提示制作 css 三角形
解决方案
.arrow_box {
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.arrow_box .arrow_boxtext {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.arrow_box .arrow_boxtext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
.arrow_box:hover .arrow_boxtext {
visibility: visible;
opacity: 1;
}
<!DOCTYPE html>
<html>
<body style="text-align:center;">
<p>Move the mouse over the text below:</p>
<div class="arrow_box">Hover over me
<span class="arrow_boxtext">your text is here</span>
</div>
</body>
</html>
DEMO看其他positions
。
.arrow_box {
position: relative;
background: #ffffff;
border: 1px solid #bebebe;
display:inline-block;
padding:5px;
}
.arrow_box:after, .arrow_box:before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(255, 255, 255, 0);
border-top-color: #ffffff;
border-width: 7px;
margin-left: -7px;
}
.arrow_box:before {
border-color: rgba(190, 190, 190, 0);
border-top-color: #bebebe;
border-width: 8px;
margin-left: -8px;
}
<html>
<body>
<div class="arrow_box">
<span>your text is here</span>
</div>
</body>
<html>
推荐阅读
- javascript - How do I (correctly) check whether an element is within the viewport in React?
- uml - UML 类 - 当没有派生类时使用基类
- php - Is it possible to tell Composer not to uninstall already installed dependencies when using the composer command?
- python - I read image file as binary strange symbols appear
- javascript - 从单位表示(rem/vh/px/...)计算(javascript)像素的最佳方法
- c# - 微服务收不到 RabbitMq 消息
- spring-boot - 尝试从 Docker 访问 ES 实例时出现 SSLHandshakeException
- python - 使用 Python 3.7+ 进行 100k API 调用,使用 asyncio 并行进行 100
- scala - 在 EMR 笔记本上安装其他 scala 库
- ios - Xcode 和 Apple Developer ID 不同