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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:48:23+00:00 2026-05-28T02:48:23+00:00

tl;dr I have an HTML+CSS page layout using positioned and scrolling boxes to simulate

  • 0

tl;dr
I have an HTML+CSS page layout using positioned and scrolling boxes to simulate a framed layout. When I click on a link to a sub-page anchor, the entire page scrolls, hiding the header.

Details:
You can see the problem here: http://phrogz.net/tmp/framed.html

  • When the browser window is tall enough that the side navigation does not overflow, clicking on a link correctly scrolls the ‘contents’ section to the header.

  • However, when the browser window is so short that the side navigation shows a sidebar, clicking on a link in the sidebar causes the entire body to scroll so that the header is off the top of the screen. Chrome, FF, and IE9 all behave similarly.

The header, sidebar and contents are all absolutely positioned to fit within the viewport and have either overflow:hidden or overflow:auto. I also have html, body { overflow:hidden }.

How can I best fix this, so that navigating to an #id on the page never scrolls the body?

I’m looking for a CSS/HTML solution; I know that I could use JavaScript hacks to ‘fix’ this, either by intercepting the click and scrolling the #contents through script as desired, or to use document.body.scrollTop = 0 after the click occurs.


Here’s a summary of the markup:

framed.html

<body>
  <article id="contents">
    <section id="section1">
      <header><h2>Section 1</h2></header>
      <!-- section 1 contents -->
    </section>
    <section id="section2">
      <header><h2>Section 2</h2></header>
      <!-- section 2 contents -->
    </section>
    <!-- more sections -->
  </article>
  <nav id="site-nav"><ul>
    <li><a href="#section1">Section 1</a></li>
    <li><a href="#section2">Section 2</a></li>
    <!-- more links -->
  </ul></nav>
  <header id="header"></header>
</body>

framed.css

html, body { margin:0; padding:0; overflow:hidden }
#header {
  overflow:hidden;
  position:absolute;
  top:0; left:0; width:100%; height:50px;
}
#contents {
  overflow:auto;
  position:absolute;
  top:50px; left:210px; right:0; bottom:0;
  padding:1em 1.5em 600px 1.5em;
}
#site-nav {
  overflow:auto;
  position:absolute;
  top:50px; bottom:0; left:0; width:210px;
}

Edit: Fixed version of the document can be seen here: http://phrogz.net/tmp/framed-fixed.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-05-28T02:48:23+00:00Added an answer on May 28, 2026 at 2:48 am

    why not try position:fixed for the #header and the #site-nav?

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

Sidebar

Related Questions

I have one page website only using HTML, CSS and JavaScript. I want to
I'm using the Blueprint CSS grid for my HTML page. I have a table
I have a page (page1.html) which references a css file (style1.css) All is good.
I am using CSS to create a 3-column page layout with header and footer.
I have the following page layout using the 960 grid systm ---------------- header -----------------
I have html and css as below - .title { display: block; background-color: red;
I have HTML + CSS text. I need some lib with simple function like
I have a html/css based menu and I'm trying to put a flash video
I have such html and css. <div class=selected> <div class=text>First</div> <div class=arrow>&nbsp;</div> </div> .selected
I have the following html/css that is causing problems in Firefox 1.5 and 2,

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.