Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8375785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:15:55+00:00 2026-06-09T15:15:55+00:00

I have a site with the navbar fixed on top and 3 divs underneath

  • 0

I have a site with the navbar fixed on top and 3 divs underneath in the main content area.

I’m trying to use scrollspy from the bootstrap framework.

I have it succesfully highlighting the different headings in the menu when you scroll past the divs.

I also have it so when you click the menu, it will scroll to the correct part of the page. However, the offset is incorrect (It’s not taking into account the navbar, so I need to offset by about 40 pixels)

I see on the Bootstrap page it mentions an offset option but i’m not sure how to use it.

I’m also not what it means when it says you can use scrollspy with $('#navbar').scrollspy(), I’m not sure where to include it so I didn’t and everything seems to be working (except the offset).

I thought the offset might be the data-offset='10' on the body tag, but it doesn’t do anything for me.

I have a feeling that this is something really obvious and I’m just missing it. Any help?

My code is

...
<!-- note: the data-offset doesn't do anything for me -->
<body data-spy="scroll" data-offset="20">
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
    <div class="container">
    <a class="brand" href="#">VIPS</a>
    <ul class="nav">
        <li class="active">
             <a href="#trafficContainer">Traffic</a>
        </li>
        <li class="">
        <a href="#responseContainer">Response Times</a>
        </li>
        <li class="">
        <a href="#cpuContainer">CPU</a>
        </li>
      </ul>
    </div>
</div>
</div>
<div class="container">
<div class="row">
    <div class="span12">
    <div id="trafficContainer" class="graph" style="position: relative;">
    <!-- graph goes here -->
    </div>
    </div>
</div>
<div class="row">
    <div class="span12">
    <div id="responseContainer" class="graph" style="position: relative;">
    <!-- graph goes here -->
    </div>
    </div>
</div>
<div class="row">
    <div class="span12">
    <div id="cpuContainer" class="graph" style="position: relative;">
    <!-- graph goes here -->
    </div>
    </div>
</div>
</div>

...
<script src="assets/js/jquery-1.7.1.min.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:15:57+00:00Added an answer on June 9, 2026 at 3:15 pm

    Bootstrap uses offset to resolve spying only, not scrolling. This means that scrolling to the proper place is up to you.

    Try this, it works for me: add an event handler for the navigation clicks.

    var offset = 80;
    
    $('.navbar li a').click(function(event) {
        event.preventDefault();
        $($(this).attr('href'))[0].scrollIntoView();
        scrollBy(0, -offset);
    });
    

    I found it here: https://github.com/twitter/bootstrap/issues/3316

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has a div with content and a navbar (looks
I have a site with a navbar made with a div element. For some
I have made a navbar at the top of my website which contains multiple
Alright, so here is the situation... Say I have a navbar for a site,
The main idea is to have a color-specific menu throughout the whole site. In
I have a small MVC site that uses the Html.ActionLink helper for a navbar.
I have a fixed navbar using curved ribbon images that have transparent bits above
My site have a utf-8 encoding (Drupal). I use include function to integrate my
So I have been experimenting with RootsTheme (which uses Bootstrap), Wordpress (from Joomla! background)
I've got a site based around tables. Basically, I have a body area and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.