javascript - 在白色背景上可见带有白色箭头的白色工具提示
问题描述
我正在尝试显示带有白色箭头的白色工具提示。与此类似的东西:
它适用于其他颜色,请参阅提供的代码,但不适用于白色。我知道白色在白色背景上根本看不到,但让它脱颖而出的最佳方法是什么?
$(function () {
$('#tooltip').tooltip('show');
});
#tooltip, {
position: relative;
color: #fff;
}
.tooltip-inner {
background: #fff;
}
.tooltip.bottom .tooltip-arrow {
border-bottom-color: #fff;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<label for="epcfLevel3Name" class="col-md-5 required">button<span id="tooltip" data-placement="bottom" title="Tooltip" class="glyphicon glyphicon-info-sign pull-right"></span></label>
解决方案
该片段的问题在于,外部 css 是在内联 css 之后应用的,因此您必须使用!important
它来覆盖它。
这是与您的屏幕截图接近的样式:
$(function() {
$('#tooltip').tooltip('show');
});
.tooltip-inner::before {
background-color: #fff;
box-shadow: -2px -2px 2px 0 rgba( 178, 178, 178, .4);
content: "\00a0";
display: block;
width: 8px;
height: 8px;
margin: auto;
position: absolute;
left: 0;
right: 0;
top: -1px;
transform: rotate( 45deg);
-moz-transform: rotate( 45deg);
-ms-transform: rotate( 45deg);
-o-transform: rotate( 45deg);
-webkit-transform: rotate( 45deg);
margin-top: 2px;
}
.tooltip-inner {
background-color: #fff !important;
color: #000 !important;
box-shadow: 0px 0px 6px #B2B2B2;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<label for="epcfLevel3Name" class="col-md-5 required">button<span id="tooltip" data-placement="bottom" title="Tooltip" class="glyphicon glyphicon-info-sign pull-right"></span></label>
推荐阅读
- python - 试图将镶木地板文件解析为熊猫数据框
- postgresql - 值包含文本或符号(>、<)的情况
- docker - 如何从 Docker 打印(到打印机)
- sql - 如何在 SQL 中执行单元格引用之类的操作?
- javascript - 尝试在 CSS 中使用绝对位置时出现问题
- node.js - Node.js E00007 Authorize.net 错误 - 由于身份验证值无效,用户身份验证失败
- java - 页面必须填满整个 ViewPager2(使用 match_parent),而我将其设置为匹配父级
- pandas - Pandas 在某些列上合并;对于其他一些列,如果不是 NaN,请向左
- c++ - 为什么 msg.message 在我的程序中不等于 WM_QUIT
- python - 用于非图像矩阵的 Keras CNN