[英]How to add a class “active” to next <div> when scrolling
我想知道是否有人可以帮助我?
我正在尝试创建一个滑块,如果用户滚动该滑块,则它将“ active”添加到下一个div,如果他们滚动则将其备份。
像这样: http : //alvarotrigo.com/fullPage/
链接到我正在工作的页面: http : //bluemoontesting.co.uk/bluemoon2016/vanhan.html
w3schools (简单的例子)
引导程序 (真实文档)
获取JavaScript (仅选择scrollspy)
Bootstrap有一个不错的Scrollspy插件可以做到这一点。
例
<!-- scrollable area -->
<body data-spy="scroll" data-target=".navbar" data-offset="50">
<!-- The navbar - The <a> elements are used to jump to a section in the scrollable area -->
<nav class="navbar navbar-inverse navbar-fixed-top">
...
<ul class="nav navbar-nav">
<li><a href="#section1">Section 1</a></li>
...
</nav>
<!-- Section 1 -->
<div id="section1">
<h1>Section 1</h1>
<p>Try to scroll this page and look at the navigation bar while scrolling!</p>
</div>
...
</body>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.