Reputation: 379
I have a php page which includes header page(navigation bar). I want to display navigation bar as fixed header but whenever change its position to fixed, it removes scrollbars (horizantal and vertical) and I am not able to scroll the page. If I want to keep my header fixed and I don't want to make position fixed. How can I achieve this ?
headerpage.php :
<div id="header" style="position:fixed;width:100%;height:100px;">
<ul>
<li>..... </li>
<li>..... </li>
<li>..... </li>
</ul>
</div>
anotherpage.php :
<?php
require("headerpage.php");
?>
<body>
some code....
</body>
Since there are 2 pages, I have created jsFiddle for my headerpage.php.
Upvotes: 0
Views: 2945
Reputation: 3065
Hey jesper did u use position:relative with position:abosulte and fixed as if you want to fix your header then you have to use all of three and may be you have to use z-index too or else there will be probelm with your site content if they have so..can you please give us proper jsfiddle so we can help..as i cant see anything instead of header..so for doing position fixed you need other part too.. P.S. i want to help so tell me and i will try..:)
Upvotes: 1
Reputation: 1655
jQuery.pin will achieve sticking elements, just like position:fixed;
.
Just download it, then implement it like this:
<script type='text/javascript' src='http://code.jquery.com/jquery-1.11.0.min.js'></script>
<script type='text/javascript' src='path/to/jquery.pin-plugin'></script>
<script type='text/javascript'>
$(function(){
$("#header").pin();
});
</script>
Upvotes: 0