I have created a “fixed” header (with scrolling) section and a “fixed” scrolling content section. (See code below).
What I cannot figure out is why when I click on the anchors that should take me to the top of the content section, it starts several lined below the actual start. This means that the “top” display is scrolled up to the point were it is not seen.
Is this a simple problem to solved or does it relate to the fact that the CSS is forcing the actual “top” to be under the “fixed heading section”?
The desire is to click on a heading link and go to the correct content section.
And within the content to be able to click on a link and go to the actual top of the section.
Here is the code I am currently using:
[code]
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″ />
<title> Scroll Under Fixed </title>
<style type=”text/css”>
/* Modified from: http://forums.devshed.com/css-help-116/content-div-scroll-header-div-338352.html */
body { padding: 155px 0 0 0; }
#header {
padding: 10px;
position: fixed;
top: 0;
left: 5px;
max-height: 150px;
width: 97%;
border:1px solid blue;
background-color: #ddd;
overflow: scroll;
display: block;
}
#content { /* long table goes here */
margin-top: 20px;
text-align: left;
display: block;
width: 99%;
padding: 5px;
line-height: normal;
font-style: normal;
border:1px solid blue;
font-weight: normal;
}
</style>
</head>
<body>
<div id=”header”></a>
<a href=”#top”> Header section 1 </a><p>
Header section 2<p>
Header section 3<p>
Header section 4<p>
Header section 5<p>
Header section 6<p>
Header section 7<p>
Header section 8<p>
Header section 9<p>
<a href=”#last”> Header section 10 </a><p>
</div>
<div id=”content”>
<h2 id=”top”> Content section 1 </h2><p>
Content section 2<p>
Content section 3<p>
Content section 4<p>
Content section 5<p>
Content section 6<p>
Content section 7<p>
Content section 8<p>
Content section 9<p>
<h2>Content section 10</h2> <a href=”#top”>top</a><p>
Content section 11<p>
Content section 12<p>
Content section 13<p>
Content section 14<p>
Content section 15<p>
Content section 16<p>
Content section 17<p>
Content section 18<p>
Content section 19<p>
<h2>Content section 10</h2> <a href=”#top”>top</a><p>
Content section 21<p>
Content section 22<p>
Content section 23<p>
Content section 24<p>
Content section 25<p>
Content section 26<p>
Content section 27<p>
Content section 28<p>
Content section 29<p>
<h2 id=”last”>Content section 30</h2> <a href=”#top”>top</a><p>
</div>
</body>
</html>