Twitter Bootstrap:Popover vs Tooltip?

Li *_*oyi 46 html css twitter-bootstrap

这两者有什么区别?对我来说,Popover看起来像一个更大的工具提示,边框更粗.是否有任何质的差异,或者只是你想要它有多大胆?

小智 44

弹出窗口需要包含工具提示.除了视觉差异,弹出窗口还可以选择显示标题和内容,而工具提示只有一个选项来显示标题.

  • 弹出窗口也可用于显示图像,如下所示:http://stackoverflow.com/questions/11075560/how-do-i-use-popover-from-twitter-bootstrap-to-display-an-image (9认同)

Fra*_*ham 12

Popvers只是工具提示的扩展,看起来有点不同,专为更多内容而设计.

例如,popovers有一个标题和内容部分,但工具提示只是内容.


Nic*_*ett 6

从语义上讲,您通常希望使用弹出窗口来提供其他相关信息。您将使用工具提示进行澄清或提示。

约夏克布丁

  • 短期或长期
  • 可以包含各种内容(例如图像,标题,列表)
  • 通常可忽略,单击或悬停时可用
  • 允许其他交互(例如按钮)
  • 旨在提供有关所关注事物的其他相关上下文

功能齐全的弹出框

工具提示

  • 少量的文字(没有其他类型的内容)
  • 通常仅在悬停时可用
  • 旨在澄清或帮助您使用重点内容

工具提示示例

UX SE的类似文章很好地解释了何时使用。


从技术上讲,没有太大区别。它们的工作方式相似。您可以使用data-属性或JS。

它们使用相同的库工作,因此具有许多相同的交互选项(悬停/焦点,内容包含,出现的一侧等)。

代码示例:

$(function() {
  $('.favorite').tooltip({
    placement: "right",
    title: "Click to mark as favorite question (click again to undo)"
  });

  $('.demo-start').popover({
    content: `
        <p>Walk through the components step by step! In this guide, you'll:</p>
        <ol>
          <li>Learn the semantics</li>
          <li>Learn the code</li>
          <li>Examine use cases</li>
        </ol>
        <div class="btn-group text-light d-flex justify-content-end" role="group" aria-label="Navigation buttons">
          <button type="button" class="btn btn-secondary" disabled><i class="fas fa-arrow-left mr-1"></i> Previous</button>
          <button type="button" class="btn btn-secondary">Next <i class="fas fa-arrow-right ml-1"></i></button>
        </div>
        `,
    html: true,
    placement: 'right',
    title: 'Welcome to the Tour!',
    trigger: 'hover focus'
  });
});
Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet">

<a class="demo-start btn btn-dark m-5" href="#" role="button">
    <i class="fas fa-play text-light mr-1"> </i> Start the Demo</a>
<br>
<i class="favorite fas fa-star m-5 text-secondary"></i>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
Run Code Online (Sandbox Code Playgroud)