[英]Bootstrap tooltip not always showing on mouseover
I'm using an icon from Font Awesome to display some text in a tooltip on a mouseover with Bootstrap.我正在使用 Font Awesome 中的图标在 Bootstrap 鼠标悬停时在工具提示中显示一些文本。 However, when I hover my mouse pointer over the icon it doesn't display the tooltip on all times.
但是,当我 hover 鼠标指针悬停在图标上时,它不会始终显示工具提示。 I've pinned the issue down to the tooltip being displayed correctly when I hover over the left half of the icon, but not when I hover over the right half of the icon.
我将问题归结为当我将 hover 放在图标的左半边时正确显示的工具提示,但当我将 hover 放在图标的右半边时却没有。 Like so:
像这样:
I'm using AdminLTE as a template to build my website.我使用AdminLTE作为模板来构建我的网站。 The issue is seen on both Edge and Chrome, I didn't test with other browsers.
这个问题在 Edge 和 Chrome 上都出现过,我没有用其他浏览器测试过。 See below the HTML, JavaScript and CSS that I'm using.
请参阅下面我正在使用的 HTML、JavaScript 和 CSS。 I insert the icon into a
card
next to a label
text.我将图标插入到
label
文本旁边的card
中。
I also found out that if I remove the data-toggle="tooltip"
declaration it works correctly.我还发现,如果我删除
data-toggle="tooltip"
声明它可以正常工作。 Albeit with the default "ugly" rendering of my browser.尽管我的浏览器默认呈现“丑陋”。
HTML: HTML:
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Settings</h3>
</div>
<form>
<div class="card-body">
<div class="form-group">
<label>Strategy</label>
<i class="fa fa-info-circle" data-toggle="tooltip" data-placement="right"
title="This is a tooltip"></i>
<input type="text" class="form-control" value="3" id="maxPositions">
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
</div>
Initialization of tooltips:工具提示的初始化:
$('[data-toggle="tooltip"]').tooltip({ boundary: 'window' })
Tooltip CSS (came with AdminLTE):工具提示 CSS(与 AdminLTE 一起提供):
.tooltip {
position: absolute;
z-index: 1070;
display: block;
margin: 0;
font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-style: normal;
font-weight: 400;
line-height: 1.5;
text-align: left;
text-align: start;
text-decoration: none;
text-shadow: none;
text-transform: none;
letter-spacing: normal;
word-break: normal;
word-spacing: normal;
white-space: normal;
line-break: auto;
font-size: 0.875rem;
word-wrap: break-word;
opacity: 0;
}
I just found a workaround, which is not a full fix to the problem: if I select any data-placement
value other than right
it renders correctly on both left and right mouseover.我刚刚找到了一个解决方法,这不是问题的完整解决方案:如果我 select 除了
right
之外data-placement
值,它在左右鼠标悬停时都会正确呈现。 If I use the value top
it renders the tooltip a bit off, to the left:如果我使用值
top
它会使工具提示有点偏离,向左:
So I was thinking maybe that's related to the issue.所以我在想也许这与这个问题有关。 Any other answers are welcome
欢迎任何其他答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.