【发布时间】:2012-04-08 06:02:58
【问题描述】:
这两者有什么区别?对我来说,Popover 看起来就像一个更大的 Tooltip,边框更厚。有什么质的区别,还是只是你想要它有多大胆?
【问题讨论】:
标签: html css twitter-bootstrap
这两者有什么区别?对我来说,Popover 看起来就像一个更大的 Tooltip,边框更厚。有什么质的区别,还是只是你想要它有多大胆?
【问题讨论】:
标签: html css twitter-bootstrap
【讨论】:
语义,您通常希望使用弹出框来提供额外的相关信息。您可以使用工具提示进行说明或提示。
A similar post from UX SE which explains well when to use which.
技术上,差别不大。它们的工作方式相似。您可以使用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'
});
});
<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>
【讨论】:
Popvers 只是工具提示的扩展,看起来有些不同,旨在提供更多内容。
例如,弹出框有标题和内容部分,但工具提示只是内容。
【讨论】: