So, I was making a personal website (at Jacob's Site 1), but i tried to center the navbar, which was created using an image and some CSS, and everything worked fine except the submenu (which is horizontal).
Here's the code for HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="description" content="">
<meta name="keywords" content="">
<title>Jacob's Site 1</title>
<link type="text/css" href="styles/styles.css" rel="stylesheet" />
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header id="logo">
<h1>Jacob's Site 1</h1>
</header>
<nav id="navbar">
<ul id="nav">
<li id="home"><a href="http://jacobssite1.bugs3.com/">Home</a></li>
<li id="programming"><a href="#">Programming</a>
<ul>
<li id="ll"><a href="#">Low-Level</a></li>
<li id="hl"><a href="#">High-Level</a></li>
<li id="scp"><a href="#">Scripting</a></li>
<li id="wnm"><a href="#">Web⁄Markup</a></li>
</ul>
</li>
<li id="aboutMe"><a href="#">About Me</a></li>
<li id="contactMe"><a href="#">Contact Me</a></li>
</ul>
</nav>
<div>
</div>
<footer id="legal">
<br />
<p>Copyright 2012 Jacob Prud'homme©</p>
<p>All rights reserved</p>
</footer>
</body>
</html>
And for CSS:
body
{
background-color: #566171;
}
header#logo
{
text-align: center;
}
ul#nav
{
list-style-type: none;
padding : 0;
margin : 0 auto;
border : 0;
top : 0px;
left : 0px;
width : 290px;
height : 25px;
background : #566171 url('../images/nav_over.gif') no-repeat;
}
a, a:link, a:visited
{
text-decoration: none;
}
p, p a
{
color: #9dbdce;
font : 12px 'Lucida Grande', LucidaGrande, Lucida, Helvetica, Arial, sans-serif;
}
/*<group=level 1>*/
ul#nav li
{
padding : 0;
margin : 0;
display : block;
float : left;
text-indent: -9999px;
}
ul#nav li a
{
border : 0;
display : block;
height : 25px;
background: url('../images/nav.gif') no-repeat;
}
ul#nav li a:hover
{
border : 0;
display : block;
background-image: url('../images/nav_over.gif');
}
/*</group>*/
/*<group=level 1 ids>*/
li#home a
{
width: 52px;
}
li#programming a
{
width: 85px;
}
li#programming a:link,
li#programming a:visited,
li#programming a:hover
{
background-position: -52px 0px;
}
li#aboutMe a
{
width: 69px;
}
li#aboutMe a:link,
li#aboutMe a:visited,
li#aboutMe a:hover
{
background-position: -137px 0px;
}
li#contactMe a
{
width: 78px;
}
li#contactMe a:link,
li#contactMe a:visited,
li#contactMe a:hover
{
background-position: -206px 0px;
}
/*</group>*/
/*<group=level 2>*/
#nav li ul
{
display : block;
visibility: hidden;
position : absolute;
left : 0px;
width : 244px;
margin : 0;
}
#nav li:hover ul
{
visibility: visible;
z-index : 100;
}
#nav li#programming ul
{
background : none;
height : 21px;
margin-left: 37px;
}
ul#nav li#programming ul li#ll a:link,
ul#nav li#programming ul li#ll a:visited
{
width : 59px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat 0px 0px;
}
ul#nav li#programming ul li#ll a:hover
{
width : 59px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat 0px -21px;
}
ul#nav li#programming ul li#hl a:link,
ul#nav li#programming ul li#hl a:visited
{
width : 61px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -59px 0px;
}
ul#nav li#programming ul li#hl a:hover
{
width : 61px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -59px -21px;
}
ul#nav li#programming ul li#scp a:link,
ul#nav li#programming ul li#scp a:visited
{
width : 54px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -120px 0px;
}
ul#nav li#programming ul li#scp a:hover
{
width : 54px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -120px -21px;
}
ul#nav li#programming ul li#wnm a:link,
ul#nav li#programming ul li#wnm a:visited
{
width : 70px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -174px 0px;
}
ul#nav li#programming ul li#wnm a:hover
{
width : 70px;
height : 21px;
background: url('../images/subnav_programming.gif') no-repeat -174px -21px;
}
/*</group>*/
footer#legal
{
text-align: center;
}
I've tried almost everything, but nothing seems to work. And, as some little warnings:
Switching the submenu's position to anything other than absolute makes the whole thing messed up,
I have the submenu's margin set to 37px because when the navbar was to the left, it aligned perfectly under the option that was supposed to be hovered over
And, i don't want it to be centered using an exact amout of pixels, because when you resize the page in a browser like Opera, everything goes wrong.
Thanks.