PDA

View Full Version : Center my nav menu


rhythmofthecosmos
09-19-2009, 11:18 PM
Hi,

I am looking to move my nav bar into the center

www.leehughes.co.uk

Am not sure how to do this, am worried about messing up the IE hacks..

ul#nav {
height:1.75em;
border-top:1px solid #000;
border-bottom:1px solid #646060;
list-style:none;
margin:0; /* reset the default left margin in IE */
padding:0 .5em 0 0; /* reset the default left padding in good browsers */
background:#000;
font-size:1em;
}
#nav li {
position:relative; /* establish stacking context for the AP'd dropdown sublist */
float:right;
padding:0;
line-height:1.75em;
}
#nav li a {
float:left;
padding:0 .5em;
border-right: 1px solid #333;
color: #CCCCCC;
text-decoration: none;
}
#nav li a.first {border:none;}

#nav li:hover,
#nav li.sfhover{
background:#transparent;/* background for all links on hover */
visibility:visible;/* makes IE7 think something changes on hover, fixes IE sticking dropdown */
}
#nav li:hover a,
#nav li.sfhover a {color:#FFF;}/*1st level font color on hover*/

/*=== All Sublist Styles ===*/
#nav ul {
position:absolute; /* position the sublist to nearest positioned ancestor, the (#nav li) in this case*/
width:12em; /*150px*/
margin-left:-999em;/* hide the sublist */
padding:0;
left:0; /* IE6/7 need this to position the sublist correctly on hover*/
top:1.75em;
background: url(fake-image.jpg);/* IE needs some sort of BG on the nested ul */
}
#nav li li {
float: none;/*reset the float from #nav li*/
display:block;
height:auto;
line-height:1.5;
border:none;/*reset borders from #nav li*/
}
#nav li li a {
float: none;/*reset the float from #nav li*/
display:block;
width:11em;/*IE6 needs a width (12em total with padding)*/
padding:0 .5em;
border:0;
}
* html #nav li li a {display:inline-block;} /*hide an overflow bug in IE6*/
*+html #nav li li a {display:inline-block;} /*hide same overflow bug in IE7*/

/*=== Hide All Sublists ===*/
#nav li:hover ul,
#nav li.sfhover ul {
margin-left:-999em;
}
/*=== Sublist Font Colors ===*/
#nav li:hover li a,
#nav li.sfhover li a {color:#FFF;} /*2nd level font color*/

#nav li li:hover a,
#nav li li.sfhover a {color:#003366;} /*2nd level font color on hover*/

/*=== Second Level UL position on hover ===*/
#nav li:hover ul,
#nav li.sfhover ul {
margin-left: 0; /* show the sublist (line up with left border on main list items)*/
}

Thanks

DWcourse
09-20-2009, 12:23 AM
Try setting the left and right margins for ul #nav to auto.

rhythmofthecosmos
09-20-2009, 12:27 AM
Tried that but not working for some reason

DWcourse
09-20-2009, 12:39 AM
I think you're going to need to add a width to ul #nav (auto?). Otherwise it's the full width of the containing div and then the list items are floating all the way to the right.