I have this HTML Code:
<div class="primaryNavigationContainer">
<ul id="menu-menu-1" class="menu">
<li id="menu-item-5" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-has-children menu-item-5"><a href="http://merrycode.com/cheekoo/wp/">Home</a>
<ul class="sub-menu">
<li id="menu-item-7" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-7"><a href="http://www.xyz.com">MerryCode</a>
</li>
<li id="menu-item-8" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-8"><a href="http://www.google.com">Google</a>
</li>
</ul>
</li>
<li id="menu-item-6" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-6"><a href="http://merrycode.com/cheekoo/wp/?page_id=2">Sample Page</a>
</li>
</ul>
</div>
And this CSS:
.menu a {
font: normal 14px Helvetica, sans-serif;
padding-left:5px;
padding-top:5px;
padding-right:5px;
float:left;
color:black;
}
.menu-item a {
text-decoration:none;
}
.menu-item:hover ul {
display:block;
}
.menu li ul {
display:none;
}
.sub-menu {
position: absolute;
top:50px;
width: 170px;
height:auto;
background: #edebeb;
z-index: 100000;
z-index: 99999;
-moz-box-shadow: 1px 1px 30px rgba(0, 0, 0, 0.06);
-webkit-box-shadow: 1px 1px 30px rgba(0, 0, 0, 0.06);
box-shadow: 1px 1px 30px rgba(0, 0, 0, 0.06);
list-style-type: none;
}
.sub-menu:after {
display: block;
}
.sub-menu a {
float: none;
}
.menu {
width:100%;
height:30px;
background-color:#ebebed;
float:left;
display: block;
list-style-type: none;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 0px;
}
(Fiddle: http://jsfiddle.net/NjpNN/)
As you can see, I am trying to create a navigation menu. Sub menu is shown when I hover the main menu item "Home" but it disappears when I try to hover over the sub-menu area.
How can I make the sub-menu stay on screen unless I move the mouse out of sub-menu area? Please keep in mind that I can not make changes to HTML as it is generated by WordPress. I need to edit my CSS to achieve this.
Example: Something like this - http://jsfiddle.net/La2L8/ (Not my code).