SlyOne
04-07-2011, 09:03 PM
Hi all,
Currently building a site & i seem to have run into a strange problem that i've never encountered before.
My goal is to create a fixed navigation bar at the very top of my page. There will be a background image acting as the container. This image is 39px in height and is repeated in the x direction. I've also added a z-index to the nav, so when the user scrolls, the navigation will always be on top of the stack.
The problem; is that when adding position:fixed to my css, it screws the navigation up. Seems to nudge the nav background image to the left instead. It works fine without the position:fixed statement, but i of course need it to reach my goal.
So my call for help, is how to code this little nav properly? My code is shown below:
The markup
<div id="fixedNav">
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#muses">Muses</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</div>
The CSS:
/* Fixed header navigation */
#fixedNav {
background: url(../images/pswd-fixedNav_01.jpg) center top;
background-repeat: repeat-x;
background-attachment: fixed;
height:39px;
z-index:100;
}
#fixedNav nav {
position:relative;
margin: 0 auto;
width:960px;
height:39px;
}
#fixedNav ul {
list-style: none;
display:inline;
position:absolute;
top:12px;
left:312px;
}
#fixedNav li {
font-size:14px;
color:#787470;
margin-right:32px;
display:inline;
}
#fixedNav li a {
text-shadow:0 1px 0 rgba(0,0,0,0.75);
text-decoration:none;
}
#fixedNav li a:hover {
border-bottom: 1px solid #787470;
}
/* end Fixed header navigation */
thanks for any help you peeps can bestow
Currently building a site & i seem to have run into a strange problem that i've never encountered before.
My goal is to create a fixed navigation bar at the very top of my page. There will be a background image acting as the container. This image is 39px in height and is repeated in the x direction. I've also added a z-index to the nav, so when the user scrolls, the navigation will always be on top of the stack.
The problem; is that when adding position:fixed to my css, it screws the navigation up. Seems to nudge the nav background image to the left instead. It works fine without the position:fixed statement, but i of course need it to reach my goal.
So my call for help, is how to code this little nav properly? My code is shown below:
The markup
<div id="fixedNav">
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#muses">Muses</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</div>
The CSS:
/* Fixed header navigation */
#fixedNav {
background: url(../images/pswd-fixedNav_01.jpg) center top;
background-repeat: repeat-x;
background-attachment: fixed;
height:39px;
z-index:100;
}
#fixedNav nav {
position:relative;
margin: 0 auto;
width:960px;
height:39px;
}
#fixedNav ul {
list-style: none;
display:inline;
position:absolute;
top:12px;
left:312px;
}
#fixedNav li {
font-size:14px;
color:#787470;
margin-right:32px;
display:inline;
}
#fixedNav li a {
text-shadow:0 1px 0 rgba(0,0,0,0.75);
text-decoration:none;
}
#fixedNav li a:hover {
border-bottom: 1px solid #787470;
}
/* end Fixed header navigation */
thanks for any help you peeps can bestow