酷炫 可配置工具提示插件 jQuery hint cs.js

  • 源码大小:9.37KB
  • 所需积分:1积分
  • 源码编号:19JP-3069
  • 浏览次数:964次
  • 最后更新:2023年05月02日
  • 所属栏目:工具提示
本站默认解压密码:19jp.com 或 19jp_com

简介

hint-css.js是hint.css库的jQuery版本,它提供了一种在任何元素上创建酷的、可配置的工具提示的简单方法。

主要功能:

  • 淡入/淡出过渡。
  • 支持HTML内容。
  • 允许您指定最大宽度和文本对齐方式。
  • 易于实现,无需JS调用。

如何使用它:

1.安装和下载。

  1. # Yarn
  2. $ yarn add hint-css.js
  3.  
  4. # NPM
  5. $ npm install hint-css.js --save

2.在HTML文件中加载必要的JavaScript和CSS文件。

  1. <link rel="stylesheet" href="/path/to/src/hint-css.css" />
  2. <script src="/path/to/jquery.min.js"></script>
  3. <script src="/path/to/src/hint-css.js"></script>

3.要将工具提示附加到元素,只需在数据提示属性,插件将处理其余部分。

  1. <button data-hint="Tooltip Content">
  2. Hover Me
  3. </button>

4.确定工具提示的位置。默认值:底部。

  1. <button data-hint="Tooltip Content" class="hint--top">
  2. Top
  3. </button>
  4.  
  5. <button data-hint="Tooltip Content" class="hint--left">
  6. Left
  7. </button>
  8.  
  9. <button data-hint="Tooltip Content" class="hint--right">
  10. Right
  11. </button>

5.确定是否允许在工具提示中显示HTML内容。

  1. <button data-hint="<b>HTML</b> Tooltips"
  2. data-hint-html="true">
  3. HTML Content
  4. </button>

6.用于自定义工具提示的更多配置选项。覆盖中的默认参数提示-css.js如下所示:

  1. $.hint.defaults = {
  2.  
  3. // additional CSS class
  4. className: null,
  5.  
  6. // time to wait before showing the tooltip
  7. delayIn: 0,
  8.  
  9. // enable/disable fade in/out transitions
  10. fade: true,
  11. fallback: '',
  12.  
  13. // w/n/s/w
  14. gravity: 'n',
  15.  
  16. // same to data-hint-html
  17. html: false,
  18. // offset in pixel
  19. offset: 0,
  20.  
  21. // opacity from 0 to 1
  22. opacity: 0.8,
  23.  
  24. // title
  25. title: 'title',
  26.  
  27. // same to data-hint-align
  28. textAlign: 'center',
  29.  
  30. // same to data-hint-max-width
  31. maxWidth: 0
  32. }

更新日志:

2022-04-19

  • 修复了显示位置错误并添加了悬停支持

预览截图