Matthew S
Matthew S

Reputation: 833

CSS menu colors

I need to differentiate colors of currently selected (i.e. active) links that are parts of the main menu vs active items that are part of a submenu.

The CSS code that I'm using for dropdown menus doesn't distinguish between active main menu items vs active submenu items. How can I change that?

I need active main menu items to remain #FEEC00 with a black background, but change active submenu items to black with a #FEEC00 background. How do I accomplish that?

Update: Added jsfiddle link

http://jsfiddle.net/Rjyvk/1/

#cssmenu {padding: 0; margin: 0; border: 0;}
#cssmenu ul, #cssmenu li {list-style: none; margin: 0; padding: 0;}
#cssmenu ul {position: relative; z-index: 597; }
#cssmenu ul li { float: left; min-height: 1px; vertical-align: middle;}
#cssmenu ul li.hover,
#cssmenu ul li:hover {position: relative; z-index: 599; cursor: default;}
#cssmenu ul ul {visibility: hidden; position: absolute; top: 100%; left: 0; z-index: 598; width: 100%;}
#cssmenu ul ul li {float: none;}
#cssmenu ul ul ul {top: 0; left: auto; right: -99.5%; }
#cssmenu ul li:hover > ul { visibility: visible;}
#cssmenu ul ul {bottom: 0; left: 0;}
#cssmenu ul ul {margin-top: 0; }
#cssmenu ul ul li {font-weight: normal;}
#cssmenu a { display: block; line-height: 1.9em; text-decoration: none; }
#cssmenu {
  background: #333;
  font-family: 'Oxygen Mono', Tahoma, Arial, sans-serif;
  font-size: 14px; 
}
#cssmenu > ul { *display: inline-block; }
#cssmenu:after, #cssmenu ul:after {
    content: '';
    display: block;
    clear: both; 
}
#cssmenu a {
    background: #333;
    color: white;
    padding: 0 20px; 
}
#cssmenu ul { text-transform: uppercase; }
#cssmenu ul ul {
      text-transform: none;
      min-width: 210px; 
}
#cssmenu ul ul a {
        background: white;
        color: black;
        border: 1px solid black;
        border-top: 0 none;
        line-height: 150%;
        padding: 5px 10px; 
}
#cssmenu ul ul ul { border-top: 0 none; }
#cssmenu ul ul li { position: relative }
#cssmenu > ul > li > a { line-height: 26px;  }
#cssmenu ul ul li:hover > a { background: #FEEC00; color: black;}

#cssmenu ul li:hover > a, #cssmenu ul li.active > a {
      background: black;
      color: #FEEC00;
}
#cssmenu ul li.has-sub > a:after {
      content: '+';
      margin-left: 5px; 
}
#cssmenu ul li.last ul {
      left: auto;
      right: 0; 
}
#cssmenu ul li.last ul ul {
        left: auto;
        right: 99.5%;

Upvotes: 0

Views: 88

Answers (1)

Jared
Jared

Reputation: 12524

Try adding the following CSS

#cssmenu .has-sub li.active > a {
    background: #FEEC00;
    color: black;
}

Fiddle

Upvotes: 1

Related Questions