Troubleshooting Bootstrap 4 Navbar Scrolling Glitches

My Django Landing page includes multiple extra description pages.

The navbar is stored in the base.html file using bootstrap 4 scrollspy, which directs to IDs on the home.html page. On the home page, it functions as shown in the official Bootstrap example.

1.ERROR

However, when navigating to other pages, the URL displays "" but remains under the URL "".

An ERROR message in the terminal also appears:

Not Found: /docs/4.3/dist/js/bootstrap.bundle.min.js
[13/Jan/2020 16:16:35] "GET /docs/4.3/dist/js/bootstrap.bundle.min.js HTTP/1.1" 404 2509

I have explored:

  • Bootstrap scrollspy when accessing from another page, which pertains to Bootstrap 3
  • and Twitter Bootstrap Scrollspy not working at all, relating to an older version of Bootstrap (+6 years old)

2.ERROR

In the original example, the highlighted area where the navbar sends users is not highlighted in my case.

3. ERROR

The navbar does not stay at the top when scrolling or clicking on any of the navbar elements.

When I attempt to implement any changes, it covers the first few lines of the page. To keep the navbar above these lines, I include the line of code:

<div class="godown-60" id="godown"></div>
.

I have tried adding classes like "fixed-top", "sticky-top":

Fixed navbar 
fixed-top 
sticky-top

base.html

<body>
  <header>
    <nav id="navbar-example2" class="navbar navbar-static-top navbar-light bg-light">
      <a class="navbar-brand" href="{% url 'home' %}" > HOME PAGE </a>
      <ul class="nav nav-pills">
        <li class="nav-item">
          <a class="nav-link" href="#about">About</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#services">Services</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#pricing">Pricing</a>
        </li>
      </ul>
    </nav>
...

home.html

<body>
  <div data-spy="scroll" data-target="#navbar-example2" data-offset="0">
    <h4 id="about">About</h4>
      <a href="{% url 'about' %}">AboutTest</a>
    <p>...</p>
    <h4 id="services">Services</h4>
      <a href="{% url 'services' %}">ServicesTest</a>
    <p>...</p>
    <h4 id="pricing">Pricing</h4>
      <a href="{% url 'pricing' %}">PricingTest</a>
    <p>...</p>
  </div>
...

Answer №1

This particular instance effectively addressed ERROR 1 and 3 (ERROR 2 was of lesser significance). Find more details here

Resolution for ERROR 1 involved utilizing a specific address (these could be actual URLs or libraries).

href="home/help/#main"
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon" href="/docs/4.0/assets/img/favicons/favicon.ico">

  <title>Illustration of Fixed Top Navbar using Bootstrap</title>

  <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/navbar-top-fixed/">

  <!-- Bootstrap core CSS -->
  <link href="../../dist/css/bootstrap.min.css" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="navbar-top-fixed.css" rel="stylesheet">
</head>


<body>
  <nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
    <a class="navbar-brand" href="#">Fixed navbar</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarCollapse">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active">
          <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="home/help/#main">Link</a>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled" href="#">Disabled</a>
        </li>
      </ul>
      <form class="form-inline mt-2 mt-md-0">
        <input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
      </form>
    </div>
  </nav>

  <!-- This addresses ERROR 3 -->
  <!-- By having a separate section -->
  <main role="main" class="container">
    <div class="jumbotron">
      <h1>Navbar Example</h1>
      <p class="lead">This is an illustration showcasing how the fixed top navbar functions. It remains affixed to the top of the browser viewport as you scroll.</p>
      <a class="btn btn-lg btn-primary" href="../../components/navbar/" role="button">View Navbar Docs »</a>
    </div>
  </main>
  <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXX -->

  <!-- Bootstrap core JavaScript
  ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery-slim.min.js"><\/script>')</script>
  <script src="../../assets/js/vendor/popper.min.js"></script>
  <script src="../../dist/js/bootstrap.min.js"></script>
</body>


</html>

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

Creating a clickable list of grouped items in Django is a versatile way to enhance user

I have grouped a list of items based on two fields class Product(models.Model): type_of_product = models.CharField(max_length=30,default="electric) made_in = models.CharField(max_length=10,choices=countries,default="UK") product= ...

Sharing functions between Angular components

Check out my problem statement: https://stackblitz.com/edit/angular-jk8dsj I'm facing two challenges with this assignment: I need to dynamically add elements in the app.component when clicking a button in the key-value.component. I've tried ...

Performing Jasmine unit testing on a component that relies on data from a service, which itself retrieves data from another service within an Angular 2+ application

Attempting to implement unit testing for a service using httpmock has been challenging. The service in question utilizes a method to make http get calls, but I have encountered difficulties in writing the test cases. saveservice.service.ts -- file const ...

Encountered an abrupt termination of JSON input while implementing Promise.all() alongside the fetch method's put operation

Encountered an issue with JavaScript while attempting to retrieve mail content from an API and update its read status simultaneously. The error message displayed in the console is: SyntaxError: Unexpected end of JSON input at inbox.js:98 The error pro ...

modifying the href attribute of a tag is determined by the value of window

I'm working on a jQuery snippet that detects the current window's URL and, depending on the href value of the window, changes the href of an anchor tag. Here's what my code looks like so far: (function($) { "use strict"; $(document).re ...

Display child component automatically upon parent component state update

The main component Dashboard manages the state for each ListItem added to my Watchlist. However, whenever I add an item, it is inserted into the database but only appears when I refresh the browser. class UserDashboard extends React.Component { state = ...

Arranging a list using Flexbox with equal spacing between elements in each row containing three items

I'm struggling with aligning a flexbox list. I have a row of 3 elements, but when there are only 2 elements on the row, there's a gap in the middle. My goal is to have a row with 2 elements look like x x o. However, my current code displays the ...

Why does the address bar show value changes in IE when using window.location.hash, but the value doesn't change in the DOM when going

Here is a sample JavaScript code that attempts to detect the back button event: document.location.hash="#1"; document.location.hash="#2"; document.location.hash="#3"; function check() { if("#3"!=window.location.hash) { alert("Back button clic ...

javascript/jquery form validation problems/support needed (jQuery)

Long story short, I am facing an issue with my code and seeking some guidance. I have various functions to perform different checks. For this particular example, I have a form with a default value of "enter name here" for one field. Here is the HTML snipp ...

Ways to manage absent embedded expressions in template literals

I'm curious about the most effective way to handle expressions in a template literal. The following code functions correctly var val1 = "Hello" var val2 = "world" var template = `${val1} ${val2}!` console.log(template) However, suppose for some rea ...

Placing the labels of checkboxes within a form into a new <p> element

I've spent hours trying, but I can't figure it out on my own. That's why I'm reaching out for help here. Here's the form I'm working with: <form id="ecommerce-form"> <input type="checkbox" id=& ...

Setting up an event listener for a newly added list through the use of node appendChild

I am currently working on dynamically adding a select list to my HTML document. While I have successfully added the node to the DOM, I am struggling with creating an event listener in a separate JavaScript file that recognizes the newly created select list ...

Is there a way to deactivate a specific JQuery function with a click of a button, while still having it enabled by default?

I am developing a video player that automatically redirects to another page once the current video finishes playing. I am looking to implement a feature that allows users to disable this automatic redirection by clicking on a 'Turn Auto Play Off Butt ...

How can you troubleshoot code in NextJS API routes similar to using console.log?

Incorporating nextjs API routes into my upcoming project has been a priority, and I recently encountered an issue with code execution upon sending a POST request. Debugging has proven to be challenging since I am unable to use conventional methods like co ...

Organizing a set of div elements based on their ID attributes

I am faced with the challenge of sorting a list of divs based on their ID values, which are in the format "indexNumber123". Instead of arranging them alphabetically, I want to sort them numerically as "indexNumber1", "indexNumber2", "indexNumber3" before d ...

Opera's extra space feature allows users to comfortably browse the

I'm attempting to insert a progress bar inside a td element within my table. Below is the code: <td style="width: 150px;"> <div style="height: 16px; max-height: 16px; overflow: hidden; border: 1px solid #80C622;"> < ...

Unable to set Object[] as an Observable<Object[]>

Currently in the midst of tackling an Angular 4 project, I have been able to troubleshoot most issues on my own so far. However, there is one error that has me stumped. I am attempting to use *ngFor (async) to showcase a list of Observable objects. Despit ...

A guide to increasing a loop counter in Vue

Having trouble looping through a specific group of objects in a multi-object array? Take a look at the code below: <template> <div> <h1>My Test App</h1> <button v-on:click="getHockeyData">Get Team Data< ...

What is the reason behind the "request aborted" error occurring when using the express res.download() method?

I am encountering an issue with the following code snippet from a node.js server utilizing the express framework: var fs = require('fs') express = require('express') handlebars = require('express-handlebars'); var he ...

Session does not reflect the correct quantity

I have encountered some issues with my account, so I am currently using my brother's account to access the e-commerce website I am working on. My main concern is regarding the handling of quantities on different pages of the website. The website con ...