I am working on a project where we’re scraping a site and pulling in the content, as a result I don’t have control over the structure of the divs or lis.
The problem I’m running into is that on the menu the drop downs aren’t left-aligning with the parent menu item. I’m looking for some css/jquery that will help solve this issue, here’s a link to the fiddle: http://jsfiddle.net/9gQCH/3/
CSS & HTML
#item1, #item2 {
background-color:#efefef;
display:inline;
font-size:14px;
margin-right:3px;
padding:5px;
}
.Submenu {
display: none;
padding: 4px;
margin-top:18px;
background-repeat:no-repeat;
}
.Menu li:hover .Submenu{
background-color:orange;
display:inline;
color: black;
padding: 3px 5px;
position:absolute;
}
<div class="Menu">
<li id="item2">
High level Item 1
<div class="Submenu">
<div>
Nested Item 1
</div>
<div>
Nested Item 2
</div>
</div>
</li>
<li id="item2">
High level Item 2
<div class="Submenu">
<div>
Nested Item 3
</div>
<div>
Nested Item 4
</div>
</div>
</li>
</div>
You don’t need jQuery for this. Simply add this to your CSS:
Update (Add
left: 0;to your.Submenuclass):(You can also add a
topproperty if you find it necessary)Fiddle: http://jsfiddle.net/kboucher/gbhtC/