clicking on internal links in the bootstrap side menu causes it to jump

Im trying to add a side menu to a help page.

The menu and internal links are functioning properly, but when clicked, the side menu partially goes behind the navbar.

As a beginner, I'm not sure how to resolve this issue. Can someone offer some guidance?

Here is the html

<div class="container-fluid info-pages">

<div class="col-md-3 col-xs-12" id="leftCol">
<h5>HELP</h5>
      <ul class="help nav nav-tabs nav-stacked" id="sidebar">
    <li><a href="#Customer_Service">Customer Service</a></li>
    <li><a href="#Shipping&delivery">Shipping & Delivery</a></li>
    <li><a href="#ReturnPolicy">Return Policy / Exchanges</a></li>
    <li><a href="#stockist">Stockist / Brand Inquiries</a></li>
    <li><a href="#webissues">Web Issues</a></li>
    <li><a href="#faq">FAQ</a></li>
  </ul>  
</div>

<div class="col-md-6 col-xs-12" id="mainCol">

    <h5 id="Customer_Service">CUSTOMER SERVICE</h5>


    <div class="col-md-6 col-xs-12">
        <ul class="customer-service">

        <li>Call: +555-5555555</li>
        <li>Email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="47252b2607252b266924282a">[email protected]</a></li>

        </ul>
    </div>

    <div class="col-md-6 col-xs-12">
        <ul class="customer-service">

        <li>Monday—Friday</li>
        <li>11:00—18:00 GMT</li>
        <li>Saturday</li>
        <li>11:00 - 18:00 GMT</li>
        <li>Sunday</li>
        <li>Closed</li>
    </ul>   
    </div>


            <br>

    <h5 id="Shipping&delivery">SHIPPING & DELIVERY</h5> 
        <p> Chartreuse master cleanse succulents, chicharrones kombucha chambray DIY green juice marfa roof party fanny pack lo-fi live-edge godard pork belly. Enamel pin venmo raclette occupy chartreuse plaid. Offal raclette live-edge venmo kale chips, humblebrag man braid hammock cliche quinoa meh mumblecore. Blue bottle gentrify ... (text continues) ... artisan crucifix, sriracha cray four loko chillwave. Next level iceland craft beer, kale chips occupy bushwick chambray schlitz hashtag hammock locavore poke squid.
        </p>    

            <br>

    <h5 id="ReturnPolicy">RETURN POLICY / EXCHANGES</h5>
        <p>Chartreuse master cleanse succulents, chicharrones kombucha chambray DIY green juice marfa roof party fanny pack lo-fi live-edge godard pork belly. Enamel pin venmo ... (text continues) ... cold-pressed pabst single-origin coffee poutine crucifix. Pitchfork artisan crucifix, sriracha cray four loko chillwave. Next level iceland craft beer, kale chips occupy bushwick chambray schlitz hashtag hammock locavore poke squid.
         </p>

         <br>

    <h5 id="stockist">STOCKIST / BRAND INQUIRIES</h5>
        <p>Chartreuse master cleanse succulents, chicharrones kombucha chambray DIY green juice marfa roof party fanny pack lo-fi live-edge godard pork belly. Enamel pin venmo ... (text continues) ... love bushwick chambray shlitz hashtag hammock locattores pokosso squido.</p>

        <br>

    <h5 id="webissues">WEB ISSUES</h5>  
        <p>Chartreuse master cleanse succulents, chicharrones kombucha chambray DIY green juice marfa roof party fanny pack lo-fi live-edge godard pork belly. Enamel pin venmo ... (text continues) ... food truck XOXO bitters af. Hot chicken bitters knausgaard four dollar toast, truffaut tousled etsy cray ice.</p>


</div>

here is the javascript

 <script type="text/javascript">
     var $body   = $(document.body);
var navHeight = $('.navbar').outerHeight(true) + 10;

$('#sidebar').affix({
      offset: {
        top: 245,
        bottom: navHeight
      }
});


$body.scrollspy({
    target: '#leftCol',
    offset: navHeight
});
</script>

Here is the .css

/*######## HELP PAGE ########## */


.info-pages{
    margin-bottom: 20vw;

    margin-top: 10vh;

        padding-top:50px;

}

.info-pages p,li {
    font-size: .9em;
}

.help{
    list-style: none;
}

.customer-service {
    list-style: none;
}


@media screen and (min-width: 768px) {
    #masthead h1 {
        font-size: 100px;
    }
}



.affix-top,.affix{
    position: static;
}

@media (min-width: 979px) {
  #sidebar.affix-top {
    position: static;
... (CSS continues) ...
    width:228px;
  }

  #sidebar.affix-bottom {
    position: relative;
  }

  #sidebar.affix {
    position: fixed;
    top:70px;
    width:228px;
  }
}

Answer №1

Here's another way to approach it:

$('nav ul li a').on('click', function (event) {
    event.preventDefault();
})

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

class-validator: ensures the correct number of digits are present in numeric values

Seeking assistance on validating the number of digits for numeric values using class-validator. Specifically, I want my entity to only accept numbers with 6 digits for a certain property. For example: const user1 = new User(); user1.code = 123456 // should ...

Having trouble with the full-screen feature not functioning properly?

I am currently in the process of creating a custom video player and I need to include a full-screen button. However, when I click on it, the video does not expand to fill up the entire screen. I am using javascript, css3, and html5 for this project. Any as ...

Javascript if-else is malfunctioning

I am having difficulty running the code below which contains if statements. I have tried removing some parts of it, but still can't get the alert to show up. Any advice would be highly appreciated. Thank you. <!DOCTYPE html> &l ...

Typehead.js on Twitter is displaying the full query instead of just the value

The Problem This is the issue I am facing with my code. My goal is to retrieve only the value, but instead of that, the entire query value is being returned. var engine; engine = new Bloodhound({ local: [{value: 'red'}, {value: 'blue&apo ...

Using jQuery to toggle the visibility of a group of radio buttons causes the div to quickly appear and disappear

My code is working perfectly as it shows up when needed and disappears when necessary. The concept behind this form is that the user can check a box, view more required form data related to the checked item, make those fields required, and then uncheck the ...

Guide to implementing bidirectional data binding for a particular element within a dynamic array with an automatically determined index

Imagine having a JavaScript dynamic array retrieved from a database: customers = [{'id':1, 'name':'John'},{'id':2, 'name':'Tim}, ...] Accompanied by input fields: <input type='text' na ...

Styling the Sidebar with a Tucked-In Header Ribbon in CSS

There are numerous methods to achieve this desired effect: I initially used a table to achieve this, but I have now chosen against using tables for that purpose. What is the most effective way to accomplish this while maintaining a right border? ...

adding a JavaScript module to a handlebars template

I have a few different files that I'm working with: In the server.js file, I have the following code: app.get('/main/:id', function(req, res) { res.render('main', { products: products }); }) Within the main.hbs file, I have ...

Utilize Vue in external files

One way I would like to improve readability in my project is by defining routes in an external file. The starting point for my Vue app is the main.js file, where I initialize everything. Take a look: import Vue from 'vue' import VueRouter from ...

Content not appearing in ng repeat loop

I'm facing a basic issue that I can't seem to solve - my code isn't working as expected: <article id="desktop"> <h3>Content: </h3> <ul> <li ng-repeat="x in storage"> name: {{x.name}} ...

Clicking on the ng-repeat will trigger the ng-click event, which populates all the data using ng

I need help including an HTML page using ng-click within ng-repeat. However, it is currently loading all the content for every ng-repeat element. My specific requirement is to only bind(ng-include) the clicked element. Please see the attachment for m ...

Browser disregards backslashes in the content of pseudo elements

I have been struggling with a simple issue for quite some time now, and I seem to be out of ideas. The problem lies in the styling of a CSS pseudo-element before, which is defined as follows: #fPhone::before{ color: #78be20; content: "\e622" ...

AngularJS filtering with multiple conditions

My ng-repeat list is currently displaying a collection of objects with a filter applied to only show objects inserted today. Here is how it looks: <div class="row msf-row" ng-repeat="record in recordlist | filter: record.date = dateJson"> Whi ...

How can I create dynamic tabs using Tailwind CSS?

I am looking to create an animated tab using React and Tailwind CSS. Here is the code I have so far: import React from 'react' import clsx from 'clsx' export const Modal = () => { const [theme, setTheme] = React.useState<' ...

Passing an object in Vue.js during a redirect

i currently have two components named projectListComponent and projectSingleComponent. I want to pass an object from component 1 to component 2 during redirection. Here is my code: projectListComponent.vue <template> <div class="row justify ...

What is the best method for eliminating a character from all elements in jQuery classes?

I am working on an Angular 4 app where every .inner-page class in a html element includes a "/". For instance: <div _ngcontent-c0="" class="inner-page /login"> <div _ngcontent-c0="" class="inner-page /register"> I need to eliminate the "/" c ...

Using Angular JS to connect Promises while preserving data

There have been discussions about chaining promises, but this scenario presents a unique challenge. I am currently working on making multiple http get requests in my code. The initial call returns an array, and for each object in this array, another http c ...

Using a directive to implement Angular Drag and Drop functionality between two tables with 1000 records

My code is functional, but there seems to be a delay in the appearance of the helper(clone) when dragging starts. I have two tables - one for the include list and another for the exclude list. Users can drag table rows from the include table to the exclud ...

When a button is undersized, the click event may not register

In my angular application, I have developed a directive for a tinyMCE editor. Upon setup, I have implemented two handlers: one for the blur event to hide the toolbar and another for the click event to show it. Additionally, I have created another directive ...

issue encountered when attempting to use string.replace with regex

When using a regex like this: I am attempting to replace "subdir" with a custom string using the string.replace method. However, when I use myStr.replace(/^.*\/\/.*\.net\/.*\/(.*)\/.*\z/, otherStr) The result is not as ...