Bootstrap 4更改工具提示箭头颜色

Die*_*ves 7 css3 twitter-bootstrap-4 bootstrap-4

我想将工具提示箭头颜色更改为红色.我用谷歌搜索了一个小时,我发现的片段不起作用.

我的最后一次尝试是:

.tooltip-arrow {
  border-right-color: red;
  border-left-color: red;
  border-bottom-color: red;
  border-top-color: red;
}
Run Code Online (Sandbox Code Playgroud)

工具提示位于右侧,向左倾斜.

小智 7

对于 Bootstrap 4.3.1

添加到 HTML 文件

<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
  Tooltip on top
</button>
Run Code Online (Sandbox Code Playgroud)

添加到 CSS 文件

.tooltip-inner {
    background-color: red;
    color: #444;
    width: auto;
    max-width: 150px;
    font-size: 100%;
    white-space: nowrap;
}

.bs-tooltip-auto[x-placement^=top] .arrow::before, .bs-tooltip-top .arrow::before {
    border-top-color: red;
}
.bs-tooltip-auto[x-placement^=right] .arrow::before, .bs-tooltip-right .arrow::before {
    border-right-color: red;
}
.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before {
    border-bottom-color: red;
}
.bs-tooltip-auto[x-placement^=left] .arrow::before, .bs-tooltip-left .arrow::before {
    border-left-color: red;
}
Run Code Online (Sandbox Code Playgroud)

添加到 Javascript 文件

$(document).ready(function () {
    $('.btn').tooltip();
});
Run Code Online (Sandbox Code Playgroud)


tmg*_*tmg 6

您正在寻找的选择器是.tooltip.bs-tether-element-attached-left .tooltip-inner::before:

.tooltip.bs-tether-element-attached-left .tooltip-inner::before {
    border-right-color: red;
}
Run Code Online (Sandbox Code Playgroud)

如果你想要每个工具提示箭头红色 - jsfiddle:

.tooltip.bs-tether-element-attached-bottom .tooltip-inner::before {
    border-top-color: red;
}

.tooltip.bs-tether-element-attached-top .tooltip-inner::before {
    border-bottom-color: red;
}

.tooltip.bs-tether-element-attached-left .tooltip-inner::before {
    border-right-color: red;
}

.tooltip.bs-tether-element-attached-right .tooltip-inner::before {
    border-left-color: red;
}
Run Code Online (Sandbox Code Playgroud)

  • 在bootstrap 4.1中你可以使用:`.bs-tooltip-auto [x-placement ^ = bottom] .arrow :: before,.bs-tooltip-bottom .arrow :: before {border-bottom-color:red!important; } .bs-tooltip-auto [x-placement ^ = top] .arrow :: before,.bs-tooltip-top .arrow :: before {border-top-color:red!important; } .bs-tooltip-auto [x-placement ^ = left] .arrow :: before,.bs-tooltip-left .arrow :: before {border-left-color:red!important; } .bs-tooltip-auto [x-placement ^ = right] .arrow :: before,.bs-tooltip-right .arrow :: before {border-right-color:red!important; }` (2认同)

Rau*_*aul 6

在bootstrap 4.1中,您可以使用:

.bs-tooltip-auto[x-placement^=bottom] .arrow::before, .bs-tooltip-bottom .arrow::before {
    border-bottom-color: red !important;
}
.bs-tooltip-auto[x-placement^=top] .arrow::before, .bs-tooltip-top .arrow::before {
    border-top-color: red !important;
}
.bs-tooltip-auto[x-placement^=left] .arrow::before, .bs-tooltip-left .arrow::before {
    border-left-color: red !important;
}
.bs-tooltip-auto[x-placement^=right] .arrow::before, .bs-tooltip-right .arrow::before {
    border-right-color: red !important;
}
Run Code Online (Sandbox Code Playgroud)