---然后总结了使用滚动监听的几个步骤
---最后给出一个简单的例子
---关键的一点:整体有点零散和乱七八糟,辛苦你的思维和眼睛了,呵呵
----------------------------------------------------------------------------------------------------------
1. Scrollspy currently requires the use of a Bootstrap nav component for proper highlighting of active links.
---- 使用滚动监听的话,导航栏必须采用 class="nav"的nav组件才可以:
下面是源代码中的一段,标红的部分可以证明这一点:
使用ScrollSpy的时候,需要采用 标签,并且在 下必须有标签。
注:另外我们需要把 标签放到另一个容器内(如div),并给父容器添加一个id属性(这一点在第4节有介绍)
1 function ScrollSpy(element, options) { 2 this.$body = $(document.body) 3 this.$scrollElement = $(element).is(document.body) ? $(window) : $(element) 4 this.options = $.extend({}, ScrollSpy.DEFAULTS, options) 5 this.selector = (this.options.target || '') + ' .nav li > a' 6 this.offsets = [] 7 this.targets = [] 8 this.activeTarget = null 9 this.scrollHeight = 010 11 this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))12 this.refresh()13 this.process()14 }
2. Navbar links must have resolvable id targets. For example, a home must correspond to something in the DOM like
查看更多关于bootstap滚动监听_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did111407