I am facing some issues with a horizontal menu. To better illustrate my problem, here is an example of the desired outcome example.
The submenu should align left with its parent, but when I add
#nav li{position:relative;}
, it ignores the left floating and the submenu's parent border from the main menu, which I cannot remove.The menu needs to have a horizontal submenu without a background, but with a border shared with the parent. Both the menu and submenu should be liquid in width.
Additionally, the challenge is to make this work in IE7.
ul#nav {
list-style: none;
padding: 0;
position: relative;
display: block;
}
#nav li {
float: left;
padding: 6px 10px;
}
#nav li:hover {
padding: 5px 9px;
border: 1px solid #000000;
}
#nav li a {
text-decoration: none;
color: #09F;
}
#nav li:hover a {
color: #000000;
}
#nav .submenu li a {
color: #3F0;
}
#nav li .submenu {
position: absolute;
left: -9000px;
}
#nav li:hover .submenu {
margin-top: 5px;
left: -1px;
border: 1px solid #000000;
}
.submenu ul {
list-style: none;
padding: 0;
float: left;
}
body {
/* added to show transparency */
padding: 20px;
background-color: #6d695c;
background-image: repeating-linear-gradient(-30deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .1) 1px, transparent 1px, transparent 60px), repeating-linear-gradient(30deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .1) 1px, transparent 1px, transparent 60px), linear-gradient(30deg, rgba(0, 0, 0, .1) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, .1) 75%, rgba(0, 0, 0, .1)), linear-gradient(-30deg, rgba(0, 0, 0, .1) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, .1) 75%, rgba(0, 0, 0, .1));
background-size: 70px 120px;
}
<ul id="nav">
<li><a href="#">Primu</a></li>
<li><a href="#">Adoilea</a>
<div class="submenu">
<ul>
<li><a href="#">submenu1</a></li>
<li><a href="#">sub2</a></li>
<li><a href="#">subtrei</a></li>
<li><a href="#">subpatru</a></li>
</ul>
</div>
</li>
<li><a href="#">trei</a></li>
<li><a href="#">patru</a></li>
<li><a href="#">cinci</a></li>
</ul>