我想知道是否有人可以帮助我?
我正在尝试创建一个 slider ,如果用户滚动,它会将“事件”添加到下一个 div,如果他们滚动备份,则反向滚动。
像这样:http://alvarotrigo.com/fullPage/
链接到我正在处理的页面:http://bluemoontesting.co.uk/bluemoon2016/vanhan.html
最佳答案
w3schools (简单的例子)
bootstrap (真实文档)
Get the 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>
关于javascript - 滚动时如何将类 "active"添加到下一个 <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36939398/