关于使用 intro 插件进行网站引导

可以到官网进行下载:https://github.com/usablica/intro.js/

引入 js 与 css 就可以了,非常方便且intro占用空间很小

<link rel="stylesheet" type="text/css" href="intro.css">

<script type="text/javascript" src="intro.js"></script>

 

使用:

添加以下属性到 需要进行引导的 HTML 代码中(比如某一个div,table)

  data-step   网站引导的第几步 (必填),

  data-intro    引导的介绍内容

  data-position   介绍内容显示在方向(left  right  top  bottom)

 

设置属性:(在 intro.js 里面)

 

01function IntroJs(obj) {
02    this._targetElement = obj;
03 
04    this._options = {
05      /* Next button label in tooltip box 下一步*/
06      nextLabel: 'Next &rarr;',
07      /* Previous button label in tooltip box 返回*/
08      prevLabel: '&larr; Back',
09      /* Skip button label in tooltip box 跳过*/
10      skipLabel: 'Skip',
11      /* Done button label in tooltip box */
12      doneLabel: 'Done',
13      /* Default tooltip box position */
14      tooltipPosition: 'bottom',
15      /* Next CSS class for tooltip boxes */
16      tooltipClass: '',
17      /* Close introduction when pressing Escape button? 是否使用键盘的Esc退出*/ 
18      exitOnEsc: true,
19      /* Close introduction when clicking on overlay layer? 是否允使点击空白的地方退出*/
20      exitOnOverlayClick: true,
21      /* Show step numbers in introduction? 是否显示说明的数据步骤*/
22      showStepNumbers: true,
23      /* Let user use keyboard to navigate the tour? 是否允许使用键盘来操作*/
24      keyboardNavigation: true,
25      /* Show tour control buttons?使用按纽操作 */
26      showButtons: true,
27      /* Show tour bullets? */
28      showBullets: true,
29      /* Scroll to highlighted element? */
30      scrollToElement: true,
31      /* Set the overlay opacity 设置弹出层的透明度*/
32      overlayOpacity: 0.8
33    };
34  }

 

 

 

之后就能看到绚丽的分步网站引导效果了!

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个使用 Intro.js 生成引导页面的示例代码。这个示例中,我们将介绍如何创建一个简单的引导页面,并使用一些样式来美化它: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Intro.js 示例</title> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/intro.js/3.3.1/introjs.min.css"> <style> .introjs-tooltip { max-width: 400px; border-radius: 3px; box-shadow: 0 0 20px rgba(0,0,0,0.3); background-color: #fff; color: #333; } .introjs-arrow { border-top-color: #fff; } .introjs-tooltipbuttons { text-align: center; } .introjs-button { background-color: #e1e1e1; color: #333; border-radius: 3px; padding: 5px 10px; margin: 5px; cursor: pointer; } .introjs-button:hover { background-color: #d2d2d2; } .introjs-button:focus { outline: none; } </style> </head> <body> <h1>Intro.js 示例</h1> <p>这是一个使用 Intro.js 创建的引导页面示例。</p> <button id="startBtn">开始引导</button> <script src="https://cdnjs.cloudflare.com/ajax/libs/intro.js/3.3.1/intro.min.js"></script> <script> document.getElementById("startBtn").addEventListener("click", function() { introJs().setOptions({ steps: [ { element: document.querySelector('h1'), intro: "这是页面的标题。" }, { element: document.querySelector('p'), intro: "这是页面的主体内容。" }, { element: document.querySelector('#startBtn'), intro: "这是开始引导按钮。", position: 'bottom' } ], showBullets: false, exitOnOverlayClick: false, exitOnEsc: false }).start(); }); </script> </body> </html> ``` 在这个示例中,我们使用了一些 CSS 样式来美化 Intro.js 的工具提示框和按钮。我们还使用了 `setOptions()` 方法来设置引导页面的参数选项,例如 `steps`、`showBullets`、`exitOnOverlayClick` 和 `exitOnEsc` 等。最后,我们在按钮的点击事件中调用 `introJs().start()` 方法启动引导页面。 你可以根据自己的需求调整这个示例代码,以生成自己的引导页面。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值