javascript - Bootstrap 工具提示位于子元素上

标签 javascript css twitter-bootstrap tooltip

我有一个像这样的 Bootstrap 工具提示 ( fiddle ):

enter image description here

<span title='Description about this' data-toggle="tooltip" data-placement="auto top">
   <i class="glyphicon glyphicon-star"></i> Some text here
</span>

我希望它与其中的图标对齐,但我想在不将弹出窗口移动到图标元素上的情况下实现这一点,因为工具提示信息的语义属于跨度。

它应该是这样的,但我不想使用这个标记:

enter image description here

<span>
   <i class="glyphicon glyphicon-star" title='Description about this' data-toggle="tooltip" data-placement="auto top"></i>
   Some text here
</span>

最佳答案

您可以使用 !important 重新定义 Bootstrap 工具提示类。

HTML:

<div class="content">
    <span title='Description about this' data-toggle="tooltip" data-placement="auto top">
       <i class="glyphicon glyphicon-star"></i> Some text here
    </span>
</div>

风格:

body{
  margin: 4em;
}
[title]{
  cursor: help;
}

.content .tooltip{
  left: 0 !important;
}

https://jsfiddle.net/cLmn9o1n/

关于javascript - Bootstrap 工具提示位于子元素上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35802056/

相关文章:

css - 如何获取CSS的最后一个Element?

html - 输入字段中的格线

css - 如何根据导航栏高度计算正文填充?

javascript - 外部样式表不会覆盖 Bootstrap

javascript - 如何使用 d3.js 库重新加载 div

javascript - 软件开发人员在学习 Javascript 时使用 jQuery 有意义吗?

javascript - 所见即所得 JavaScript HTML 编辑器,具有 API 和高级文本处理支持(如单词检测)

html - Firefox 中不显示绝对居中的图像

javascript - 节点 - 已找到 @import 循环

html - Twitter Bootstrap 响应式导航栏 - 居中链接