【问题标题】:How to change the font of Bootstrap tooltips如何更改 Bootstrap 工具提示的字体
【发布时间】:2016-05-21 23:29:57
【问题描述】:

使用 bootstrap.js 中包含的 Tooltip 插件,如何更改工具提示内的文本所用的字体?无论我多么努力,我唯一的成功就是更改了我的 * 选择器中定义的文本。我的引导程序是使用 jQuery 激活的:$(".myTooltip").tooltip({html: "true", placement: "auto-right", delay: {"show": 300, "hide": 100}});
工具提示显示在此图片旁边:
<img title="<ul class='text-left'><li>Some text</li><li><em>More Text</em></li><li>Cost</li></ul>" class="myTooltip" src="image.png" />

【问题讨论】:

    标签: javascript twitter-bootstrap tooltip


    【解决方案1】:

    Bootstrap 通过两个类来装饰工具提示 - .tooltip.tooltip-inner。这是来自bootstrap.css的片段:

    .tooltip {
      font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
      font-size: 12px;
      font-style: normal;
      font-weight: normal;
      line-height: 1.42857143;
      text-align: left;
      text-align: start;
      text-decoration: none;
      text-shadow: none;
      text-transform: none;
      letter-spacing: normal;
      word-break: normal;
      word-spacing: normal;
      word-wrap: normal;
      white-space: normal;
      /* ... */
    }
    .tooltip-inner {
      max-width: 200px;
      padding: 3px 8px;
      color: #fff;
      text-align: center;
      background-color: #000;
      border-radius: 4px;
    }
    

    所以你可以自己设置工具提示:

    jQuery(document).ready(function($) {
      $(".my-tooltip").tooltip({
        html: "true", 
        placement: "auto-right", 
        delay: {"show": 300, "hide": 100}
      });
    });
    @import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
    
    body {
      padding: 20px;
    }
    .tooltip {
      font-family: Georgia;
      font-size: 20px;
    }
    .tooltip .tooltip-inner {
      background-color: #ffc;
      color: #c00;
      min-width: 250px;
    }
    <img title="<ul class='text-left'><li>Some text</li><li><em>More Text</em></li><li>Cost</li></ul>" class="my-tooltip" src="https://i.stack.imgur.com/ssdlq.jpg" />
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-03
      • 2011-06-07
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多