I have used css to make a "sticky header" that is always visible at the top of the page and the other content placed below it. In the header I have some internal links. The problem is that when a link is clicked then the page is scrolled so that the target is positioned at the top of the page - hidden by my sticky header - instead of just below it.
Any suggestions on how to solve this problem?
css:
#header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 3.5em;
padding:0;
margin: 0;
}
#container {
width: 100%;
margin: 3.5em 0 0 0;
padding: 0;
overflow:auto;
}
#content {
padding: 0 4em;
margin: 0;
}
html:
<body>
<div id="header">
<div id="content">
<p>
<a href="#xyz">XYZ</a>
</p>
</div> <!--end content-->
</div> <!--end header-->
<div id="container">
<div id="content">
<p>A lot of text.</p>
<a name="xyz"></a>
<p>A lot of text</p>
</div><!--end content-->
</div><!--end container-->
</body>