In viewing all of those examples, you missed one of the key points, that the sub ul goes inside its parent li:
Code:
<li><a href="">button</a>
<ul>
<li><a href="">sub-button</a></li>
<li><a href="">sub-button</a></li>
</ul>
</li>
But there are lots of problems with the CSS, too, so I've tidied it up for you in the example below. I removed the surrounding div, as that's not needed, and also it's best to avoid all those negative top and left positions and negative margins etc. That's a sign of poor layout strategy anyway.
If you like, we can help you with the larger layout as well.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
body, ul, li {margin:0; padding: 0;}
#nav {
float: right;
display: block;
margin: 0 0 0 0;
list-style: none;
}
#nav > li {
float: left;
font-size: 16px;
position: relative;
margin-left: 5px;
}
#nav a {
text-decoration: none;
color: #000;
font-family: Trebuchet MS, sans-serif;
font-weight: bold;
padding: 8px 13px 8px 13px;
border-color: #000;
border-style: solid;
border-width: 0 2px 2px;
display: block;
}
#nav a:link, a:visited {
color: #000;
-webkit-transition: color .25s linear .05s;
transition: color .25s linear .05s;
}
#nav a:hover {
color: #fff;
background: #000;
}
#nav ul {
position: absolute;
left: -9999px;
list-style: none;
}
#nav li:hover ul {
left: 0;
}
</style>
</head>
<body>
<ul id="nav">
<li><a href="">button</a>
<ul>
<li><a href="">sub-button</a></li>
<li><a href="">sub-button</a></li>
</ul>
</li>
<li><a href="">button</a></li>
<li><a href="">button</a></li>
<li><a href="">button</a></li>
</ul>
</body>
</html>
Bookmarks