我将html分为几层,第四层是站点的菜单,第五层是包含内容的区域。
这是代码段
<body>
<main data-spy="scroll" data-target=".menu-list" data-offset="50">
<div class="top-layer">
</div>
<div class="second-layer">
</div>
<div class="third-layer">
</div>
<div class="fourth-layer sticky-top">
<div class="container text-center">
<ul class="menu-list inline-list">
<li class="">
<a class="" href="#experiences">Experiences</a>
</li>
<li class="">
<a class="" href="#education">Education</a>
</li>
<li class="">
<a class="" href="#skills">Skills</a>
</li>
<li class="">
<a class="" href="#portfolio">Portfolio</a>
</li>
<li class="">
<a class="" href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
<div class="fifth-layer">
<div class="container">
<div class="content-area border" id="experiences">
</div>
//other divs with ids
</div>
</div>
</main>
</body>
我在可滚动的主标记中添加了data-spy
。但这似乎不起作用。我可能还没有完全理解scrollspy的概念,但是一直在试图弄清为什么它不起作用。有人可以帮我解释一下吗?