简体   繁体   English

如何在下一个课程中添加“活动”课程 <div> 滚动时

[英]How to add a class “active” to next <div> when scrolling

I'm wondering if anyone can help me? 我想知道是否有人可以帮助我?

I'm trying to create a slider where if the user scrolls then it adds "active" to the next div and if they scroll backup if reverses. 我正在尝试创建一个滑块,如果用户滚动该滑块,则它将“ active”添加到下一个div,如果他们滚动则将其备份。

Like this: http://alvarotrigo.com/fullPage/ 像这样: http : //alvarotrigo.com/fullPage/

Link to the page im working on: http://bluemoontesting.co.uk/bluemoon2016/vanhan.html 链接到我正在工作的页面: http : //bluemoontesting.co.uk/bluemoon2016/vanhan.html

w3schools (easy example) w3schools (简单的例子)

bootstrap (real documentation) 引导程序 (真实文档)

Get the javascript (select only scrollspy) 获取JavaScript (仅选择scrollspy)

Bootstrap has a nice Scrollspy plugin to do just that. Bootstrap有一个不错的Scrollspy插件可以做到这一点。

Example

<!-- 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM