Scrollspy active class in Bootstrap 4.0.0-beta.2 fails to update with scroll movement on webpage

I've been working on creating my own personal landing page using HTML, consisting of three sections. I have successfully implemented the functionality where these sections are reachable through links on a navigation bar. However, I encountered an issue where the link highlighting does not reflect the current part of the page when scrolling. Instead, it remains stuck at the default position set in the HTML.

If you want to take a look at my code and preview the page, you can find it here. Notice how the blue highlight doesn't update as you scroll through different sections of the page.

Here is the body declaration:

<body data-spy="scroll" data-target="#spy" data-offset="70">

And this is how my navigation bar is set up:

<!-- Navbar -->
<nav id="spy" class="navbar fixed-bottom navbar-light bg-light">

    <a class="nav navbar-brand" href="#"></a>

    <ul class="nav nav-pills">
        <li class="nav-item"> <a class="nav-link active" href="#about_me"> about me></a> </li>
        <li class="nav-item"> <a class="nav-link" href="#portfolio"> portfolio </a> </li>
        <li class="nav-item"> <a class="nav-link" href="#contact_me"> contact me </a> </li>
    </ul>

</nav>

As for the rest of the content:

<div class="bg-light p-3 rounded">
        <p id="About_Me"> Cat ipsum dolor sit amet... </p>
    ...

Despite following similar implementations that worked before and troubleshooting online resources, I still face the issue of link highlighting not updating while scrolling through the page. Can somebody provide insights on how to resolve this problem?

Answer №1

In order to fix the issue with your scrollspy not working, you must include or reference popper.js. This is a dependency that Bootstrap relies on.

If you don't have popper.js, your JavaScript will encounter errors causing the scrollspy feature to malfunction.

For an updated working example, check out this CodePen link with the necessary references, including Popper.js from CDNJS.

You can also test it out on Codeply, which automatically includes Bootstrap and its dependencies for convenience.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Applying CSS styles to highlighted text using jQuery - how can I do it

Struggling to style selected text with CSS? Here's what I've tried so far without success in Firefox. $(document).keyup(function(){ savedRange = selection.getRangeAt(0); $(savedRange).wrap('<span style="color:red"></span>' ...

The Carousel feature functions properly with 3 or more slides, but malfunctions when there are only 2 slides present

After implementing a minimal carousel, I discovered that it functions perfectly with 3 or more slides. However, as soon as I remove some slides, issues start to arise. Some of the problems I encountered include: The sliding animation is removed on ' ...

Is there a Polar transformation available in CSS3?

Converting a line into a ring is a straightforward process in graphic design software like GIMP: https://i.sstatic.net/7lQZe.png (source: adamhaskell.net) I'm exploring the possibility of achieving the same effect using CSS. Here's what I&ap ...

Uniform selection frame width across nested list elements

I want to ensure that the width of the selection frame for all nested ul li elements is consistent, just like in this example. When hovering over an element (making the entire line clickable), I don't want any space on the left. Currently, I am using ...

Specify touch event regions with the ngTouch directive

I recently implemented ngTouch in my AngularJs web app to detect swipe left and right gestures. I am using this feature to open and close a side bar menu. Currently, the swipe events are linked to the entire wrapper like this <div ng-style="body_st ...

Setting the height of a span element to 100% within a table using

I have a table with some content inside. One of the elements is an <a class="available">available</a>, but it doesn't fill the entire row of the table. Here is the HTML code: <table with="100%" class="list_table"> <tbody> < ...

Retrieving the first five rows from a table with data entries

My task involves working with a table named mytbl, which contains 100 rows. I need to extract only the first five rows when a user clicks on "Show Top Five." Although I attempted the following code, the alert message returned 'empty': var $upda ...

Is there a Safari glitch related to floating elements?

I stumbled upon a strange issue with the layout I've been working on, and it led me to this concise code snippet that seems to be causing misrendering in desktop Safari. It appears that the div#shim element is what's triggering the text misrender ...

The resizing function on the droppable element is malfunctioning on Mozilla browsers

I've been working on making one div both droppable and resizable. Surprisingly, everything is functioning perfectly in Chrome but not in Firefox. If you'd like to see the issue for yourself, here is my jsFiddle demo that you can open in Firefox: ...

Decide on the chosen option within the select tag

Is there a way to pre-select an option in a combobox and have the ability to change the selection using TypeScript? I only have two options: "yes" or "no", and I would like to determine which one is selected by default. EDIT : This combobox is for allow ...

Automate Chrome browser to continuously refresh until desired item is located using Selenium and Chromedriver

I am attempting to create a Python script using selenium that will continuously refresh the current Chrome page until a specific item, identified by driver.find_element_by_partial_link_text("Schott"), is found. This is what I had in mind: while not drive ...

Implementing a permanent class following an incident

Is it possible to dynamically add a class to an element when an event occurs rather than based on a condition? For example, I have a td that displays a variable. <td>{{myVar}}</td>//myVar=10 When the variable changes to myVar=15, I want to ad ...

Tips for highlighting text in HTML without using a specific tag

My current project involves customizing a Wordpress plugin, but I've encountered a frustrating obstacle. I'm having trouble removing the three dots that appear at the bottom of the download card. Despite my efforts, I can't seem to find any ...

What is the best way to automatically hide the Materialize CSS mobile navbar?

Recently, I completed a website called Link. Using only Materialize CSS, Vanilla JS, and plain CSS, I developed a single-page application that effectively hides and reveals different sections based on event listeners. Everything functions smoothly except ...

Employ JQuery and Ajax to develop an autocomplete/suggestion feature that generates a list based on JSON data fetched from an API via PHP

I'm facing challenges in developing a dynamic auto-suggest feature for a search field using JQuery with data in JSON format. The JSON data is fetched from an API through PHP. The objective is to have the auto-suggest list update with each keystroke e ...

What is the best approach to incorporating two distinct grid layouts within a single section?

I am attempting to replicate the header-graphic navigation found on this website: It appears that they are not using a grid for the header-graphic area, but rather keeping them separated as 2 divs within their Hero block container. I am interested in recr ...

Trouble with jQuery .click() function not functioning as expected

After reviewing several stackoverflow questions regarding issues with the .click function not working, I am still unable to resolve my problem. I have correctly imported the jquery libraries. <script src="https://ajax.googleapis.com/ajax/libs/jquer ...

Looking for a solution to save data without internet access through a web application

My goal is to develop a web application using HTML5, CSS3, and potentially JQuery Mobile. The purpose of this app will be to gather customer data through a form, with the added requirement of being able to operate offline. In the past, I have built offlin ...

Images do not appear on Bootstrap Carousel as expected

I am facing an issue where the images are not displaying on my bootstrap carousel or when I try to display them individually using their class. I am utilizing bootstrap and express for my project. I have verified multiple times that the file path to the im ...

Navigating through a Collection of Pictures using Mouse Movement and Left-click Button

Trying to create a customized PACS viewer for scrolling through a series of CT head images. However, encountering an issue with scrolling through all 59 images. Currently, able to scroll from the first to the 59th image, but struggling to loop back to the ...