I am encountering an issue with scrollspy on Bootstrap version 5.1. Despite following the examples in the documentation (links provided below), I am unable to make it work; there are no visible changes when scrolling.
My goal is for the corresponding link in the navbar to become active as the user scrolls through different sections of the page.
- Official Docs: https://getbootstrap.com/docs/5.1/components/scrollspy/
- Test Site:
- Site Code:
HTML Structure
<body data-bs-spy="scroll" data-bs-target="#navbar">
...
<nav id="navbar" class="menu">
<ul class="nav flex-column">
<li class="nav-item active"><a class="nav-link" href="#about">About me</a></li>
<li class="nav-item"><a class="nav-link" href="#skills">Skills</a></li>
<li class="nav-item"><a class="nav-link" href="#services">Services</a></li>
<li class="nav-item"><a class="nav-link" href="#projects">Projects</a></li>
</ul>
</nav>
...
<section id="about"> ... </section>
<section id="skills"> ... </section>
<section id="services"> ... </section>
<section id="projects"> ... </section>
</body>