AMP: Is it possible to highlight page menu on user

2019-08-29 11:24发布

Can we highlight page menu as the user scroll down or up on the AMP page? Here is the demo code for the same with javascript. Below is the HTML code:

<nav>
  <ul id="mainNav">
    <li class="active"><a href="#home">Home</a></li>
    <li><a href="#work">Work</a></li>
    <li><a href="#about">About</a></li>
    <li><a href="#contact">Contact</a></li>    
  </ul>
</nav>
<section id="home"><h2>Home</h2></section>
<section id="work" data-sr><h2>Work</h2></section>
<section id="about"><h2>About</h2></section>
<section id="contact"><h2>Contact</h2></section>

How can we achieve same functionality in AMP too i.e. top navigation changing automatically as the user scrolls?

0条回答
登录 后发表回答