CSS center navigation bar
The navigation bar must be centered and the li elements must be floated so they will be horizontal also a background image must be applied when hovering links.
by Xenios
HTML
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="wrap">
<div id="nav_container">
<div id="nav">
<div>
<ul>
<li><a href="#">About Us</a></li>
<li class="separator"><a href="#">Our Products</a></li>
<li class="separator"><a href="#">FAQs</a></li>
<li class="separator"><a href="#">Test</a>
<ul>
<li><a href="#">sub item 1</a>
<li><a href="#">sub item 2</a>
</ul>
</li>
<li class="separator"><a href="#">Contact</a></li>
<li class="separator"><a href="#">Login</a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
CSS
#wrap {
width: 1366px;
margin: 0 auto;
}
#nav_container {
width: 1366px;
height: 65px;
background: transparent url(http://imageshack.us/a/img208/60/navmiddle.png) repeat-x;
margin: 15px 0 15px 0;
clear: left;
}
#nav {
clear:both;
margin:0 auto;
overflow:hidden;
padding:0;
text-align:center;
width:100%;
}
#nav div {
float:left;
left:50%;
position:relative;
margin-bottom:5px;
}
#nav ul {
list-style-image:none;
list-style-position:outside;
list-style-type:none;
}
#nav li {
float:left;
list-style-image:none;
list-style-position:outside;
list-style-type:none;
font-family: helvetica, arial, verdana, tahoma;
margin-left:auto;
margin-right:auto;
position:relative;
right:50%;
padding: 22px 30px 19px 30px;
}
#nav .separator{
background: url(http://imageshack.us/a/img651/8259/menuseperatorx.png) left 10px no-repeat;
}
#nav li a {
font-size: 18px;
color: white;
text-decoration: none;
}
#nav ul li:hover {
background: url(http://imageshack.us/a/img96/965/navhoverg.png) repeat-x;
}
/*Submenu items*/
#nav ul ul {
display:none; /* Sub menus are hiden by default */
position:absolute;
top:2em;
left:0;
right:auto; /*resets the right:50% on the parent ul */
}
#nav ul ul li {
left:auto; /*resets the left:50% on the parent li */
margin:0; /* Reset the 1px margin from the top menu */
clear:left;
width:100%;
}
#nav ul ul li a,
#nav ul li.active li a,
#nav ul li:hover ul li a,
#nav ul li.hover ul li a { /* This line is required for IE 6 and below */
font-size:.8em;
font-weight:normal; /* resets the bold set for the top level menu items */
background:#eee;
color:#444;
line-height:1.4em; /* overwrite line-height value from top menu */
border-bottom:1px solid #ddd; /* sub menu item horizontal lines */
}
#nav ul ul li a:hover,
#nav ul li.active ul li a:hover,
#nav ul li:hover ul...