提示工具 | Tooltips

使用CSS和JavaScript添加自定义引导工具提示的文档和示例,使用CSS 3进行动画和本地标题存储的数据属性。

概述

使用工具提示插件时要知道的事情:

工具提示依赖于第三派对库Popper.js用于定位。你必须包括popper.min.js在引导.js或使用bootstrap.bundle.min.js/bootstrap.bundle.js其中包含Popper.js,以便工具提示能够工作%21。

如果从源头构建我们的JS,要求util.js...

由于性能原因,工具提示可以选择,因此你必须自己初始化...

没有显示零长度标题的工具提示。

指定container: 'body'为了避免在更复杂的组件(如我们的输入组、按钮组等)中呈现问题,%29。

触发隐藏元素的工具提示将无法工作。

工具提示.disabled或disabled元素必须在包装器元素上触发。

当从跨越多行的超链接触发时,工具提示将居中。使用white-space: nowrap;你的为了避免这种行为。

在从DOM中删除相应的元素之前,必须隐藏工具提示。

都明白了吗?太好了,让我们看看他们是如何用一些例子来工作的。

示例:随时随地启用工具提示

初始化页面上所有工具提示的一种方法是通过data-toggle属性:

$(function () {

$('[data-toggle="tooltip"]').tooltip()

})

实例

在下面的链接上悬停以查看工具提示:

打开 getbootstrap.com 上的示例

静态演示

有四个选项可用:上、右、底和左对齐。

打开 getbootstrap.com 上的示例

交互式演示

悬停在下面的按钮上,查看它们的工具提示。

打开 getbootstrap.com 上的示例

Tooltip on top

Tooltip on right

Tooltip on bottom

Tooltip on left

并添加了自定义HTML:

Tooltip with HTML

使用

工具提示插件按需生成内容和标记,默认情况下将工具提示放在触发器元素之后。

通过JavaScript触发工具提示:

$('#example').tooltip(options)

标记

工具提示所需的标记仅为data属性和title在HTML元素上,您希望有一个工具提示。生成的工具提示标记相当简单,尽管它在默认情况下需要位置%28,设置为top插件%29。

使工具提示对键盘和辅助技术用户有效

您应该只向传统上具有键盘焦点和交互式%28的HTML元素添加工具提示,例如链接或表单控件%29。尽管任意HTML元素%28,例如S%29可以通过添加tabindex="0"属性,这将为键盘用户在非交互元素上添加潜在的烦人和令人困惑的制表符。此外,大多数辅助技术目前在这种情况下不公布工具提示。

Hover over me

Some tooltip text!

备选方案

选项可以通过数据属性或JavaScript传递。对于数据属性,将选项名追加到data-,如data-animation=""...

Name

Type

Default

Description

animation

boolean

true

Apply a CSS fade transition to the tooltip

container

string | element | false

false

Appends the tooltip to a specific element. Example: container: 'body'. This option is particularly useful in that it allows you to position the tooltip in the flow of the document near the triggering element - which will prevent the tooltip from floating away from the triggering element during a window resize.

delay

number | object

0

Delay showing and hiding the tooltip (ms) - does not apply to manual trigger type If a number is supplied, delay is applied to both hide/show Object structure is: delay: { "show": 500, "hide": 100 }

html

boolean

false

Allow HTML in the tooltip. If true, HTML tags in the tooltip's title will be rendered in the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks.

placement

string | function

'top'

How to position the tooltip - auto | top | bottom | left | right.When auto is specified, it will dynamically reorient the tooltip. When a function is used to determine the placement, it is called with the tooltip DOM node as its first argument and the triggering element DOM node as its second. The this context is set to the tooltip instance.

selector

string | false

false

If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example.

template

string

'

Base HTML to use when creating the tooltip. The tooltip's title will be injected into the .tooltip-inner. .arrow will become the tooltip's arrow. The outermost wrapper element should have the .tooltip class.

title

string | element | function

''

Default title value if title attribute isn't present. If a function is given, it will be called with its this reference set to the element that the tooltip is attached to.

trigger

string

'hover focus'

How tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. manual cannot be combined with any other trigger.

offset

number | string

0

Offset of the tooltip relative to its target. For more information refer to Popper.js's offset docs.

fallbackPlacement

string | array

'flip'

Allow to specify which position Popper will use on fallback. For more information refer to Popper.js's behavior docs

个别工具提示的数据属性

可以通过使用数据属性来指定单个工具提示的选项,如上文所述。

方法

异步方法和转换

所有API方法都是异步然后开始过渡.他们会在过渡开始后立即返回给呼叫者,但是在它结束之前此外,方法调用转换组件将被忽略。...

有关更多信息,请参阅我们的JavaScript文档。

$().tooltip(options)

将工具提示处理程序附加到元素集合。

.tooltip('show')

显示元素的工具提示。在实际显示工具提示之前返回给调用方。%28i.e.。在shown.bs.tooltip事件发生%29。这被认为是工具提示的“手动”触发。没有显示零长度标题的工具提示。

$('#element').tooltip('show')

.tooltip('hide')

隐藏元素的工具提示。在工具提示实际隐藏之前返回给调用方。%28i.e.。在hidden.bs.tooltip事件发生%29。这被认为是工具提示的“手动”触发。

$('#element').tooltip('hide')

.tooltip('toggle')

切换元素的工具提示。在工具提示实际显示或隐藏之前返回给调用方。%28i.e.。在shown.bs.tooltip或hidden.bs.tooltip事件发生%29。这被认为是工具提示的“手动”触发。

$('#element').tooltip('toggle')

.tooltip('dispose')

隐藏并销毁元素的工具提示。使用委托%28创建的工具提示大selector期权%29不能在子代触发器元素上单独销毁。

$('#element').tooltip('dispose')

.tooltip('enable')

使元素的工具提示具有显示的能力。默认情况下,工具提示是启用的。

$('#element').tooltip('enable')

.tooltip('disable')

移除显示元素的工具提示的能力。工具提示只有在重新启用时才能显示.

$('#element').tooltip('disable')

.tooltip('toggleEnabled')

切换元素的工具提示显示或隐藏的能力。

$('#element').tooltip('toggleEnabled')

.tooltip('update')

更新元素的工具提示的位置。

$('#element').tooltip('update')

事件

Event Type

Description

show.bs.tooltip

This event fires immediately when the show instance method is called.

shown.bs.tooltip

This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).

hide.bs.tooltip

This event is fired immediately when the hide instance method has been called.

hidden.bs.tooltip

This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).

inserted.bs.tooltip

This event is fired after the show.bs.tooltip event when the tooltip template has been added to the DOM.

$('#myTooltip').on('hidden.bs.tooltip', function () {

// do something…

})

© 2011–2017 Twitter, Inc.

©2011-2017自带作者

根据麻省理工学院的许可授权的代码。

根据CreativeCommonsAttributionLicense v3.0授权的文档。

https://getbootstrap.com/docs/4.0/Components/ToolTIPS/

html显示tooltips,提示工具 | Tooltips相关推荐

  1. 第二十二课--提示工具(Tooltip)

    <!DOCTYPE html> <html lang="en"> <head><meta charset="UTF-8" ...

  2. ucharts提示窗tooltips自定义format配置,换行展示标题

    ucharts提示窗tooltips默认显示格式,显示横轴数据+类别+纵轴数据,如下图所示 现在我们希望横轴类别显示为在第一行显示为标题: 修改ucharts中的config-ucharts.js和u ...

  3. npm install tooltips 提示插件:popper.js

    Popper.js 是一个扩展性较好的 tooltips 提示类 JS 插件,不需要依赖 jQuery 库,大小仅为 3.5KB 左右,使用与配置相当简单,若你的 Web 网站有这个需要,可以尝试使用 ...

  4. Tableau 合集3:格式设置之可视化图显示百分比和提示工具对齐问题

    一.前言 本文通过可视化图中显示不了百分比和提示工具无法对齐两个小问题出发,介绍了关于Tableau设置格式和工具提示的一些使用方法. 环境:Windows11 64位.Tableau desktop ...

  5. 悬浮提示工具(悬浮出现自动消失)

    之前做过的提示工具是使用bootstrap的模态窗做的,有人说并不好,需要点击关闭,设置时间较长 但是那个提示工具就是为了时间较长,必须看到才做的,也就是说,设计之初的目的就是出现错误才看到的反馈. ...

  6. 教你玩转CSS 提示工具(Tooltip)

    如何使用 HTML 与 CSS 来创建提示工具. 提示工具在鼠标移动到指定元素后触发 基础提示框(Tooltip) 提示框在鼠标移动到指定元素上显示: <style>/* Tooltip ...

  7. 我的前端工具集(五)提示工具之模态窗提示

    我的前端工具集(五)提示工具之模态窗提示   liuyuhang原创,未经允许禁止转载 目录 我的前端工具集 1.需求 很多页面操作都需要提示,比如操作成功,操作失败之类. 总不能没事就console ...

  8. html5 tooltip,HTML5 教程之CSS 提示工具(Tooltip)

    CSS 提示工具(Tooltip) 本文我们为大家介绍如何使用 HTML 与 CSS 来创建提示工具. 提示工具在鼠标移动到指定元素后触发,先看以下四个实例: 头部显示 右边显示 底部显示 左边显示 ...

  9. a按钮居中显示 bootstrap_Bootstrap提示冒泡样式

    使用提示冒泡持件时的注意事项: Tooltip提示冒泡组件依赖于 Popper.js ,你必须将popper.min.js 文件放在 bootstrap.js之前调用,或者使用 bootstrap.b ...

  10. AMD(ATI)Mobility笔记本显示驱动修改工具DH Mobility Modder.NET 1.2.1.0正式版

    笔记本显示驱动已经是个老生常谈的话题,这个原本可以通过显示芯片厂商像对待桌面显卡那样经常推出官方公版驱动,从而将所有问题都迎刃而解的状况,由于某些笔记本厂商"一己私利",演变成了困 ...

最新文章

  1. 2018-4-8使用兔子的例子对比说明遗传算法,局部搜索,禁忌搜索,模拟退火方法
  2. java泛型集合_Java泛型集合(Set)
  3. 求职学习笔记|并发编程知识点常见问题总结(一)
  4. qq浏览器打开word 技术原理_知道为什么计算机可以上网的同时,可以写word还可以听歌吗?...
  5. 【第一章】MySQL数据概述
  6. linux多线程加解锁
  7. 苹果证实将弃用Windows版QuickTime
  8. composer 安装
  9. AVR单片机(ATmega128)单片机运算乘除法大约所需时间
  10. Questa-sim安装最后一步点了是之后,安装了hardlock.sys文件导致电脑无限蓝屏重启的解决方案
  11. 编写程序,求柱体的体积:
  12. 【WPS表格】一些简单函数
  13. css超链接样式+雪碧图实现导航
  14. 联想thinkpad E430c 重装系统之后无线连接显示红叉解决办法
  15. Excel中如何使用COLUMN和COLUMNS函数
  16. C++11 智能指针shared_ptr一篇足以
  17. win10+NVIDIA geforce gtx 960M+cuda9.0+cudnn7.1+pytorch_1.1.0+torchvision_0.3.0---已解决
  18. GitHub年度报告,爆全球程序员画像!
  19. Samplitude pro x4完美汉化破解版|Samplitude pro x4 64位完美汉化破解版(附汉化包)下载 v15.0.1.139
  20. 吴恩达深度学习编程作业报错解决方法汇总

热门文章

  1. BZOJ2434: [Noi2011]阿狸的打字机
  2. python 战舰_在python中的战舰游戏
  3. bitbake的原理介绍, 使用方法, 编译脚本的编写方法
  4. 未明学院:还没入职就被“裁员”,大批应届生遭千亿巨头强制解约! Sorry,秋招 Offer 我们决定撤回…
  5. $java_home位置_关于java home:echo $ JAVA_HOME不返回jdk位置
  6. 移动光猫RAISECOM的配置方法
  7. moment 的使用 当月第一天
  8. 利用Python实现某度贴吧签到脚本「云函数模拟客户端」
  9. Babylongjs-纹理
  10. 线和面的方程区别_直线方程和平面方程的区别