Bootstrap 滚动监听(Scrollspy)插件
来源:互联网 发布:淘宝的限时秒杀在哪里 编辑:程序博客网 时间:2024/05/16 18:32
滚动监听(Scrollspy)插件,即自动更新导航插件,会根据滚动条的位置自动更新对应的导航目标。其基本的实现是随着您的滚动,基于滚动条的位置向导航栏添加 .active class。
如果您想要单独引用该插件的功能,那么您需要引用 scrollspy.js。或者可以引用 bootstrap.js 或压缩版的bootstrap.min.js。
创建水平滚动监听,html代码
<!DOCTYPE html><html><head><title>Bootstrap 滚动监听(Scrollspy)插件</title><meta charset="utf-8"><link rel="stylesheet" href="css/bootstrap.min.css"><script src="js/jquery.min.js"></script><script src="js/bootstrap.min.js"></script><style>body {position: relative;}.container-fluid2 {padding-top: 50px;height: 500px;color: #fff;}p{font-size:24px;}</style></head><body data-spy="scroll" data-target=".navbar" data-offset="50"><nav class="navbar navbar-inverse navbar-fixed-top"><div class="container-fluid"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="#">WebSiteName</a></div><div><div class="collapse navbar-collapse" id="myNavbar"><ul class="nav navbar-nav"><li><a href="#section1">课程1</a></li><li><a href="#section2">课程2</a></li><li><a href="#section3">课程3</a></li><li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">课程4<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="#section41">课程4-1</a></li><li><a href="#section42">课程4-2</a></li></ul></li></ul></div></div></div></nav><div id="section1" class="container-fluid2" style="background-color: blue; padding-top: 100px;"><h1>课程1</h1><p>Try to scroll this section and look at the navigation bar while scrolling! </p><p>Try to scroll this section and look at the navigation bar while scrolling!</p></div><div id="section2" class="container-fluid2" style="background-color: purple;"><h1>课程2</h1><p>Try to scroll this section and look at the navigation bar while scrolling! </p> <p>Try to scroll this section and look at the navigation bar while scrolling! </p></div><div id="section3" class="container-fluid2" style="background-color:red;"><h1>课程3</h1><p>Try to scroll this section and look at the navigation bar while scrolling! </p> <p>Try to scroll this section and look at the navigation bar while scrolling! </p></div><div id="section41" class="container-fluid2" style="background-color:green;"><h1>课程4-1</h1><p>Try to scroll this section and look at the navigation bar while scrolling! </p> <p>Try to scroll this section and look at the navigation bar while scrolling! </p></div><div id="section42" class="container-fluid2" style="background-color: orange;"><h1>课程4-2</h1><p>Try to scroll this section and look at the navigation bar while scrolling! </p> <p>Try to scroll this section and look at the navigation bar while scrolling! </p></div></body></html>效果图
0 0
- Bootstrap 滚动监听(Scrollspy)插件
- Bootstrap 下拉菜单和滚动监听(Scrollspy)插件
- Bootstrap的js插件之滚动监听(scrollspy)
- Bootstrap插件(二)——滚动监听(scrollspy.js)
- bootstrap学习32---滚动监听scrollspy.js
- Bootstrap基础17——滚动监听scrollspy
- Bootstrap滚动监听插件
- BootStrap 滚动监听插件
- Bootstrap插件scrollspy源码的学习
- bootstrap下拉菜单和滚动监听插件
- 4.4Bootstrap学习js插件篇之滚动监听
- Bootstrap Scrollspy Plugin
- bootstrap之scrollspy
- bootstrap滚动监听
- bootstrap滚动监听示例
- bootstrap监听滚动
- bootstrap滚动监听
- Bootstrap中的滚动监听
- Java中 VO、 PO、DO、DTO、 BO、 QO、DAO、POJO的概念
- rocketMq 在windows系统上的使用
- centos7离线安装Docker
- linux下安装python3
- SSH原理与运用(一):远程登录
- Bootstrap 滚动监听(Scrollspy)插件
- CentOS 7 LNMP环境搭建Zabbix3.0
- JavaScript中,二分法递归示例
- ArcGIS中的地理坐标系转换方法参数
- Happy Birthday Newtown Casino Bonus RM 38, RM 88 & RM 128
- WCF来传递DataTable的Bug
- 详解softmax函数以及相关求导过
- STOMP Protocol
- C++抽象编程——字符串(3)——字符串判断与大小写转换