Hi,
If the issue is that that when you follow a fragment identifier the text slides under the fixed header then that is a downside of using fixed elements I'm afraid.
You could use the :target pseudo class (ie9+) to add some padding to the top of the targetted element to move it under the fixed header.
e.g.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
body { padding:100px 0 0; }
h1 {
height:100px;
border:1px solid #000;
position:fixed;
z-index:99;
background:red;
margin:0;
line-height:100px;
top:0;
right:0;
left:0;
}
h2 { margin:0 0; }
h2:target{padding-top:100px}
</style>
</head>
<body>
<h1>Header</h1>
<h2 id="section1">Section 1 starts here</h2>
<p><a href="#section2">Go to section 2</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2 id="section2">Section 2 starts here</h2>
<p><a href="#section3">go to section 3</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2 id="section3">Section 3 starts here</h2>
<p><a href="#section4">go to section 4</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2 id="section4">Section 4 starts here</h2>
<p>test <a href="#section1">go to section 1</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</body>
</html>
Of course should the page content not be tall enough under the target element then you will get a gap above the targeted element as it only scrolls to the top of the page when there is not enough room on the page to see all of it.
For older browsers there is no other choice but to use js and scroll the content into view or add a dummy id/element that is set xxpx above where you want the page to scroll to.
e.g.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
body { padding:0}
h1 {
height:100px;
border:1px solid #000;
position:fixed;
z-index:99;
background:red;
margin:0;
line-height:100px;
top:0;
right:0;
left:0;
}
h2 { margin:0 0; }
p{height:25px;margin:0}
</style>
</head>
<body>
<h1>Header</h1>
<p id="section1"> </p>
<p> </p>
<p> </p>
<p> </p>
<h2>Section 1 starts here</h2>
<p><a href="#section2">Go to section 2</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p id="section2">test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2>Section 2 starts here</h2>
<p><a href="#section3">go to section 3</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p id="section3">test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2>Section 3 starts here</h2>
<p><a href="#section4">go to section 4</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p id="section4">test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<h2>Section 4 starts here</h2>
<p>test <a href="#section1">go to section 1</a></p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</body>
</html>
Of course that is rather convoluted and not always easy to implement in a varied page.
Bookmarks