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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:07:52+00:00 2026-05-17T19:07:52+00:00

I have a page with a header position:fixed DIV at the top . This

  • 0

I have a page with a header position:fixed DIV at the top. This DIV is height:300px and it is fixed so that it’s always visible even when users scroll down.

My content is in another DIV below. It has a position:absolute with a top:300px. So when you first load the page, it starts below my header and when you scroll, it scroll underneath my header which stays fixed at the top.

In my content DIV, I have multiple anchor. When I click a link to one of these anchor, the page scrolls but places the anchor right at the top of the page. So basically, the content that was supposed to be displayed is hidden under my header…

Do you have any idea how to fix this problem with HTML/CSS..?

Is there another solution apart from using iframe or a frameset..?

  • 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-05-17T19:07:53+00:00Added an answer on May 17, 2026 at 7:07 pm

    You can do it with jquery.

    First you need to include the jquery library in you <head> f you aint already.

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    

    under the above you need the following javascript

    <script type="text/javascript">
    $(function(){
    
        $('a[href*=#]').click(function() {
    
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
            && location.hostname == this.hostname) {
    
                var $target = $(this.hash);
    
                $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
    
                if ($target.length) {
    
                    var targetOffset = $target.offset().top - 300;
    
                    $('html,body').animate({scrollTop: targetOffset}, 10);
    
                    return false;
    
                }
    
            }
    
        });
    
    });
    </script>
    

    The following line from the above script controls the offset, or ‘margin’ from the top.

    var targetOffset = $target.offset().top - 300;
    

    You can also make the scroll smooth by increasing the value on this line.

    $('html,body').animate({scrollTop: targetOffset}, 10);
    

    try replacing it with this.

    $('html,body').animate({scrollTop: targetOffset}, 1000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CSS layout that simulates a fixed-frame page, with a header and
I wish to have a page that has a fixed height (without scroll bars).
Lets say that I have a header user control in a master page, and
I have a setup that requires a header div and a footer div to
I have three DIVs, something like this: <div id=header> ... </div> <div id=content> <div
I have a header that is larger than the width of the page so
I have this html page which globally exists of div , section , and
I have a site that features a fixed header, the problem is that it
I have a Crystal Report with a formula on the page header like this:
Out of the box SSRS reports cannot have data exposed in the page header.

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.