I have a menu with sub nav items. I have some jquery so that when you are on a page with subnav the subnav is showing. However I want to adapt it so that if you also hover over the menu item which has a subnav then you can choose one of the options. At the moment the subnav disappears once you roll off the parent. Any ideas?
header nav ul.topnav li ul
{
position: absolute;
top:48px;
left: 35px;
width: 940px;
height: 28px;
padding: 0;
display:none;
}
header nav ul.topnav li ul.active
{
display: block;
}
header nav ul.topnav li ul li
{
background:none; /* removes separator from subnav */
height: 28px;
line-height: 24px;
margin: 0;
padding: 0;
}
header nav ul.topnav li ul li:hover
{
line-height: 24px;
margin: 0;
padding: 0;
}
header nav ul.topnav li ul li:hover a,
header nav ul.topnav li ul li a
{
float: left;
display: block;
height: 28px;
line-height: 15px;
font-size:12px;
color: #575759;
text-shadow: none;
margin:3px 0 0 0;
padding: 0 15px;
}
header nav ul.topnav li ul li:first-child a
{
padding-left: 0;
}
header nav ul.topnav li ul li a:hover
{
color: #52AA26;
}
header nav ul.topnav li:hover ul li a
{
-moz-box-shadow:none;
-webkit-box-shadow:none;
box-shadow:none;
background:none;
}
hi, thank you for taking the time to look at the code.
The main issue is that when I click on a subnav item and the parent is active. So I am on the page subnav one and about us is highlighted. Then I hover over our services - the subnav shows but over the top of the current active subnav. Not sure how to make it work best I think. Think I need to hide the current active subnav when I hover over the new parent with subnav.
Any ideas?
06-19-2012, 08:31 PM
OlsenQuinn
I know this is old but it's the reason i registered :)
You have space between the topnav and subnav. I am guessing because you wanted to separate the a elements more or what not.
Simple solution, always make sure you have no space between the topnav and subnav. If you need to create separation, use padding not margin or positioning.
Code:
header nav ul.topnav li ul {
display: none;
height: 2px;
left: 35px;
padding: 0;
position: absolute;
/*top: 48px;*/ //change this
top: 40px;
padding-top:8px;
width: 940px;
}