parent menu background colour

andrew67
andrew67 used Ask the Experts™
on
hi folks i have a drop down menu done in css "i could really learn to hate them" any way this is the url
http://www.nuvaring.aa9/patientsitemap

my problem is when i move my mouse onto one of the sub menu items the main menu background colour reverts back to the on on mouse out action.

the css im using is below

.menu {height:25px;  z-index:100;padding-left:10px; background-color:#ffe383;  }
#nav
{
      font-size:75%;
      height:25px;
      line-height:25px;
      width:730px;
      float:left;
      list-style: none;
}
#nav {
      padding: 0;
      margin: 0;

}
#nav a {
      display: block;
      /*width: 140px;*/
      color:#000;
      text-decoration:none;
      /*width:11em;*/
}
#nav a:hover
{
      color:#FFF;
      background-color:#FBBB37;
}
#nav li {
      float: left;
      width: 9em;
      padding-left:3px;
      width:140px;
}
#nav li a:hover
{
      color:#FFF;
      background-color:#FBBB37;
}
#nav li ul {
      position: absolute;
      width:128px;
      left: -999em;
      background-color:#FBBB37;
}
#nav li ul li {
      padding:6px;
      line-height:15px;
      margin-left:0px;
      width:128px;
      background-color:#FBBB37
}
/*
#nav li ul li a,#nav li ul li a:howver
{
      width:140px;
}
*/
#nav li:hover ul {
      left: auto;

}
#nav li:hover ul, #nav li.sfhover ul {
      left: auto;
}

any help really really aprieciated
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Your link isn't working, but what you are experiencing is default behavior. If you want the parent to maintain the "mouseover" aka :hover style while you're browsing the submenu, you'll need some custom javascript to go along with your CSS.

Author

Commented:
your right the link is the wrong one this one works
http://nrd.anytimeafter9.co.uk/patientsitemap

however your answer isnt really what i wanted to hear

Commented:
*shrug* It's still the right one :) :hover is very basic.  You need more functionality than it provides.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
any more clues than that???
Commented:
Actually...

ul#nav li:hover
{

}

Put your a:hover stuff in that.

Author

Commented:
i have a function to get the drop downs to work in ie6 any idea how i can get the top menu bg to stay coloured in ie6???

Author

Commented:
sorry this is the function
sfHover = function() {
      var sfEls = document.getElementById("nav").getElementsByTagName("LI");
      for (var i=0; i<sfEls.length; i++) {
            sfEls[i].onmouseover=function() {
                  this.className+=" sfhover";
            }
            sfEls[i].onmouseout=function() {
                  this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
            }
      }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

Commented:
Afraid I can't see a way to do it.  The parent li would need an explicit ID first, otherwise you'd be setting all the parents at the same time.  But I can't think of a way to walk up the tree... maybe I'm just tired.  I hope someone else sees this that can help.
Consultant & Challenge Subduer
Top Expert 2009
Commented:
Try this:

#nav a,
#nav li:hover li a
 {
	display: block;
	color:#000;
	text-decoration:none;
}
 
#nav a:hover,
#nav li:hover a
{
	color:#FFF;
	background-color:#FBBB37;
}

Open in new window

Author

Commented:
hi all sorry for the delay getting back, ive actually found a really good solution here

http://www.cssplay.co.uk/menus/dd_valid.html

just use a different menu simpler and one that works

thanks for all your help

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial