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 8886085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:28:20+00:00 2026-06-14T21:28:20+00:00

I have a fixed navigation bar on my website that stays at the top

  • 0

I have a fixed navigation bar on my website that stays at the top with links that take me to different sections further down the page. However, because my fixed nav bar has a height of 40px, the beginning 40px of every section is covered up. How would I offset where my links take me by 40px using either HTML or CSS?
Thanks.

  • 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-14T21:28:21+00:00Added an answer on June 14, 2026 at 9:28 pm

    You might try absolutely positioning “dummy” anchors 40 pixels above the top of each section. You can give them zero width/height and hidden visibility to ensure that these anchors don’t affect how your page is displayed. When the user clicks one of the links in your fixed navigation bar, the window will scroll to the top of the dummy anchor, 40 pixels above the beginning of its actual section.

    Example HTML:

    <div class="navbar">
      <a href="#anchor1">Anchor 1</a>
      <a href="#anchor2">Anchor 2</a>
      <a href="#anchor3">Anchor 3</a>
    </div>
    <div class="section">
      <span id="anchor1" class="anchor"></span>
      Section Content
    </div>
    <div class="section">
      <span id="anchor2" class="anchor"></span>
      Section Content
    </div>
    <div class="section">
      <span id="anchor3" class="anchor"></span>
      Section Content
    </div>​
    

    Example CSS:

    body {
        padding-top: 40px;
    }
    .navbar {
        position: fixed;
        width: 100%;
        height: 40px;
        top: 0;
        left: 0;
        z-index: 10;
        border-bottom: 1px solid #ccc;
        background: #eee;
    }
    .section {
        position: relative;
    }
    .anchor {
        display: block;
        position: absolute;
        width: 0;
        height: 0;
        z-index: -1;
        top: -40px;
        left: 0;
        visibility: hidden;
    }
    

    For a working example, see http://jsfiddle.net/HV7QL/

    Edit: CSS3 also includes the :target pseudo-class, which applies to an element whose id has been referenced by the href of a link in the document, or the hash value of the URL. You can apply a 40-pixel padding to the top of the :target that will be applied only to the section the user selects from the fixed navbar.

    Example CSS:

    .section:target {
        padding-top: 40px;
    }
    

    This is semantically cleaner than the method described above, but won’t work on older browsers.

    Working example: http://jsfiddle.net/5Ngft/

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

Sidebar

Related Questions

I have a single page website with the navigation menu position:fixed at the top
So i have a long scrolling 1page website with a fixed navigation bar. With
What I want to do is have a fixed navigation bar that is 10px
I have a layout of fixed-pixel width (960px) with a navigation bar that has
On the following website, www.josecvega.com , I have a navigation bar with years that
I have a navigation bar that I would like to keep at a fixed
I have a single-page scrolling website. It uses a fixed-position nav bar with jquery
I have a simple navigation bar at the top of the page with several
I have a navigation bar on my website. The HTML: <nav id=navigation> <a href=index.html>
I had this idea for a website of creating a fixed horizontal navigation bar

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.