I am trying to create a centred pure CSS drop down menu, but am struggling with the implementation. Problem summary:
- The first menu is transparent and overlapping the other, which it shouldn't
- I'm not able to put the menus side-by side
- Im unable to centre the menus on the page
- I'm unable to get rid of the transparent gap between the link background and the edge of the list
- I'd like to select by clicking on the box surrounding the link. Now I have to click on the link itself.
Here's a JSFiddle example: http://jsfiddle.net/nxq55ppr/1/
Here's the HTML:
<div class="menuitems">
<div class="menuouter"><div class="menuinner">First menu<ul>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="/#">Ipsum</a></li>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="/#">Ipsum</a></li>
</ul></div></div>
<div class="menuouter"><div class="menuinner">Second menu<ul>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="/#">Ipsum</a></li>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="/#">Ipsum</a></li>
</ul></div></div>
And here's the CSS:
.menuinner {
margin: 10px;
padding: 10px;
border: 2px solid purple;
width: 200px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
position: absolute;
}
.menuinner > ul { display: none; }
.menuinner:hover > ul { padding: 0; margin: 0; list-style-type: none; display: block; background: #f9f9f9; border-top: 1px solid purple;}
.menuinner:hover > ul > li { list-style-type:none; padding: 5px; display: block;}
.menuinner:hover > ul > li:hover { background: #ccc;}
.menuinner:hover > ul > li:hover > a { color: red; }