scrollspy bootstrap 4

<!-- The 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-expand-sm bg-dark navbar-dark fixed-top">
...
  <ul class="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>

3.67
3
Autotune 150 points

                                    &lt;nav id=&quot;navbar-example2&quot; class=&quot;navbar navbar-light bg-light&quot;&gt;
  &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Navbar&lt;/a&gt;
  &lt;ul class=&quot;nav nav-pills&quot;&gt;
    &lt;li class=&quot;nav-item&quot;&gt;
      &lt;a class=&quot;nav-link&quot; href=&quot;#fat&quot;&gt;@fat&lt;/a&gt;
    &lt;/li&gt;
    &lt;li class=&quot;nav-item&quot;&gt;
      &lt;a class=&quot;nav-link&quot; href=&quot;#mdo&quot;&gt;@mdo&lt;/a&gt;
    &lt;/li&gt;
    &lt;li class=&quot;nav-item dropdown&quot;&gt;
      &lt;a class=&quot;nav-link dropdown-toggle&quot; data-toggle=&quot;dropdown&quot; href=&quot;#&quot; role=&quot;button&quot; aria-haspopup=&quot;true&quot; aria-expanded=&quot;false&quot;&gt;Dropdown&lt;/a&gt;
      &lt;div class=&quot;dropdown-menu&quot;&gt;
        &lt;a class=&quot;dropdown-item&quot; href=&quot;#one&quot;&gt;one&lt;/a&gt;
        &lt;a class=&quot;dropdown-item&quot; href=&quot;#two&quot;&gt;two&lt;/a&gt;
        &lt;div role=&quot;separator&quot; class=&quot;dropdown-divider&quot;&gt;&lt;/div&gt;
        &lt;a class=&quot;dropdown-item&quot; href=&quot;#three&quot;&gt;three&lt;/a&gt;
      &lt;/div&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/nav&gt;
&lt;div data-spy=&quot;scroll&quot; data-target=&quot;#navbar-example2&quot; data-offset=&quot;0&quot;&gt;
  &lt;h4 id=&quot;fat&quot;&gt;@fat&lt;/h4&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;h4 id=&quot;mdo&quot;&gt;@mdo&lt;/h4&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;h4 id=&quot;one&quot;&gt;one&lt;/h4&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;h4 id=&quot;two&quot;&gt;two&lt;/h4&gt;
  &lt;p&gt;...&lt;/p&gt;
  &lt;h4 id=&quot;three&quot;&gt;three&lt;/h4&gt;
  &lt;p&gt;...&lt;/p&gt;
&lt;/div&gt;

3.67 (3 Votes)
0
4.25
8

                                    &lt;!-- Bootstrap 5 Scrollspy --&gt;
&lt;nav id=&quot;navbar-example2&quot; class=&quot;navbar navbar-light bg-light px-3&quot;&gt;
   &lt;a class=&quot;navbar-brand&quot; href=&quot;#&quot;&gt;Navbar&lt;/a&gt;
   &lt;ul class=&quot;nav nav-pills&quot;&gt;
      &lt;li class=&quot;nav-item&quot;&gt;
         &lt;a class=&quot;nav-link&quot; href=&quot;#fat&quot;&gt;@fat&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class=&quot;nav-item&quot;&gt;
         &lt;a class=&quot;nav-link&quot; href=&quot;#mdo&quot;&gt;@mdo&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class=&quot;nav-item dropdown&quot;&gt;
         &lt;a
            class=&quot;nav-link dropdown-toggle&quot;
            data-bs-toggle=&quot;dropdown&quot;
            href=&quot;#&quot;
            role=&quot;button&quot;
            aria-expanded=&quot;false&quot;
            &gt;Dropdown&lt;/a
         &gt;
         &lt;ul class=&quot;dropdown-menu dropdown-menu-end&quot;&gt;
            &lt;li&gt;&lt;a class=&quot;dropdown-item&quot; href=&quot;#one&quot;&gt;one&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a class=&quot;dropdown-item&quot; href=&quot;#two&quot;&gt;two&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;hr class=&quot;dropdown-divider&quot; /&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a class=&quot;dropdown-item&quot; href=&quot;#three&quot;&gt;three&lt;/a&gt;&lt;/li&gt;
         &lt;/ul&gt;
      &lt;/li&gt;
   &lt;/ul&gt;
&lt;/nav&gt;
&lt;div
   data-bs-spy=&quot;scroll&quot;
   data-bs-target=&quot;#navbar-example2&quot;
   data-bs-offset=&quot;0&quot;
   tabindex=&quot;0&quot;
&gt;
   &lt;h4 id=&quot;fat&quot;&gt;@fat&lt;/h4&gt;
   &lt;p&gt;...&lt;/p&gt;
   &lt;h4 id=&quot;mdo&quot;&gt;@mdo&lt;/h4&gt;
   &lt;p&gt;...&lt;/p&gt;
   &lt;h4 id=&quot;one&quot;&gt;one&lt;/h4&gt;
   &lt;p&gt;...&lt;/p&gt;
   &lt;h4 id=&quot;two&quot;&gt;two&lt;/h4&gt;
   &lt;p&gt;...&lt;/p&gt;
   &lt;h4 id=&quot;three&quot;&gt;three&lt;/h4&gt;
   &lt;p&gt;...&lt;/p&gt;
&lt;/div&gt;

4.25 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
ScrollSpy bootstrap 3 bootstrap 5 scrollspy via javascript example bootstrap scrollspy via javascript example bootstrap scroll spy with js scrollspy in bootstrap what is scrollspy in bootstrap? bootstrap scrollpy scrollspy bootstrap5 bootstap data-spy scroll nedir scrollspy bootstrap 5 example Bootstraps Scroll Spy Bootstrap4 Scrollspy scrollspy example bootstrap 4 code how to add get bootstrap scrollspy how to add get bootstrapp scrollspy bootstrap scrollspy how to use scrollspy in bootstrap scrollspy in bootstrap 5 how to use scroll spy in my bootstrap website scrollspy bootstrap 4 example Scrollspy bootsrap Scrollspy without bootstrap Bootstrap Scrollspy Plugin auto scrollspy bootstrat Bootstrap 5 scrollspy php Bootstrap 3 scrollspy div scrollspy sections bootstrap 4 bootstrap 5 scrollspy example bootstrap 5 scrollspy without bootstrap bootstrap scrollspy standalone javascript scrollspy bootstrap bootstrap 4.1 scrollspy down what is scrollspy in bootstrap scroll spy bootstrap bootstrap scrollspy js download bootstrap smooth scrollspy bootstrap scrollspy template scroll to container scrollspy bootstrap 5 scrollabe container scrollspy bootstrap 5 scrollspy bootstrap 5 bootstrap 3 scrollspy bootstrap scroll spy scrollspy easy bootstrap scrollspy in bootstrap 4 scrollspy bootstrap bootsrap scrollspy example css bootstrap scrollspy example css bootstrap scrollspy example data-spy= scroll bootstrap 4 scrollspy bootstrap javascript bootstrap 5 scrollspy scrollspy bootstrap 4 bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy bootstrap scrollspy Bootstrap 4 Scrollspy
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source