Z-Indexed drop down menu not diplaying above a following div ul - css

I have added a second row on my menu_Box called menu_Box2
Trying my shot at Z-Indexing for the first time.
I cannot to get the menu_Box drop down menu to appear above menu_Box2 items.
Ive tried some different z-Index, overflow and position values with no luck.
I think I may need to Z-index some of the ul li items, but since they are group together its difficult for me to figure out which ones.
CSS:
#menu_Box{ /*MENU BOX CONTAINER*/
width: 890px;
height: 100%;
margin: 0 auto;
padding-left: 10px;
z-index:500
}
#menu_Box2{ /*MENU BOX CONTAINER*/
width: 890px;
height: 100%;
margin: 0 auto;
padding-left: 10px;
padding-top:6px;
overflow:visible;
}
#menu_Box ul,
#menu_Box2 ul{ /*MENU BOX STYLE*/
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
color:rgba(0, 57, 96, .95);
font-size:24px;
font-weight:normal;
padding:0 0 0 8px;
margin:0;
position:relative;
}
.extraStyle{
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
color:rgba(0, 57, 96, .85);
font-size:22px;
font-weight:normal;
padding:0 0 0 7px;
margin:0;
}
#menu_Box ul li,
#menu_Box2 ul li{
display:inline-block;
}
#menu_Box ul li:hover,
#menu_Box ul li a:hover,
#menu_Box2 ul li:hover,
#menu_Box2 ul li a:hover{
color:#456692;
text-decoration:none;
}
#menu_Box ul li a,visited,
#menu_Box2 ul li a,visited{
text-align:left;
color:#263A75;
display:block;
padding: 0 0 0 0; /*Padding between titles*/
text-decoration:none;
}
#menu_Box ul li:hover ul,
#menu_Box ul ul li,
#menu_Box2 ul li:hover ul,
#menu_Box2 ul ul li{
display:block;
}
#menu_Box ul ul,
#menu_Box2 ul ul{ /*Drop Down Box*/
border: 3px solid rgba(0, 57, 96, .85) ;
display:none;
position:absolute;
background-color: rgba(139, 183, 212, .9);
padding: 3px 5px 3px 5px; /*Padding between list items*/
}
#menu_Box ul ul li a,visited,
#menu_Box2 ul ul li a,visited{
color:#263A75;
}
#menu_Box ul ul li a:hover,
#menu_Box2 ul ul li a:hover{
color:#456692;
}
HTML:
<div id="menu_Box"> <!--Menu Box Div-->
<ul>
<li>Services
<ul>
<li>Psych-K </li>
<li>Food & Environmental Allergy and Sensitivity Testing </li>
<li>Supplement and Nutrition Evaluation </li>
<li>Food Value Testing </li>
</ul>
</li><span class="extraStyle">::</span>
<li>Sessions </li><span class="extraStyle">::</span>
<li>Biography </li><span class="extraStyle">::</span>
<li>Health Topics
<!-- <ul>
<li>Open Source Forums </li>
<li>Open Source Forums </li>
</ul>-->
</li><span class="extraStyle">::</span>
<li>Favorite Products</li><span class="extraStyle">::</span>
<li>Contact </li>
</ul>
</div> <!--Close Menu Box Div-->
<div id="menu_Box2"> <!--Menu Box Div-->
<ul>
<li>Recipies
</ul>
</div> <!--Close Menu Box Div-->

The z-index property only applies to positioned elements, so add position: relative; to your #menu_Box

Add z-index:500 to menu_Box ul not menuBox (I would use z-index 1, not z-index 500 because it is just enough to go above menu_Box2)
CSS:
#menu_Box ul
{
z-index:1;
}
This works because you need to add it to the 'popup-box', not the text.
DEMO

Related

Count indicator adds extra spaces in a CSS menu

I need to add Faceboook style count indicators to a CSS menu. You can see it here: JSFIDDLE
The problem is that count indicators (with orange background) creates extra spaces and I can't understand why.
First problem:
As you can see in the above image, the texts "Two" and "Four" (with number indicators) are placeed 1px lower than texts "One" and "Three" (without number indicators).
Second problem:
As you can see the width of left and right margins of the text "Two" (with number indicator) are different. The with of left margin is 10px as it should be but the width of right margin is 15px.
My code:
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:0px auto;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
a span.badge{
position:relative;
top:-16px;
right:5px;
margin:0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
HTML
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>
here is your answer, what you have to do is
a span.badge{position:absolute;} but at the same time you have to change the
li a{position:relative} to control the position of the badges check the code below.
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:10px auto 0px;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000; position:relative; display:inline-block;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
li a{ position:relative; display:inline-block;}
a span.badge{
position:absolute;
top:-5px;
right:0px;
margin:0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>
You need to give the badges an absolute position, inside a relative parent, and set some proper margins to them.
#xx2menu > li > a{
color: #fff;font-weight:700;position: relative;
}
a span.badge{
position:absolute;
top:0;
right:5px;
margin:-7px -7px 0 0;
}
http://jsfiddle.net/ufj27m4w/12/
Add position: relative to #xx2menu > li or #xx2menu > li > a and position: absolute to a span.badge
html{height:100%;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote{padding:0;margin:0;}
body{cursor:default;font:11px/13px verdana,tahoma,arial;color:#333;background-color:#ffffff;}
div#xx2menus{margin:0px auto;width:968px;height:36px;background:#5B4B40;background: -webkit-linear-gradient(#776753, #5B4B40);background: -o-linear-gradient(#776753, #5B4B40);background: -moz-linear-gradient(#776753, #5B4B40);background: linear-gradient(#776753, #5B4B40);border:1px solid #362D26;border-radius:3px;z-index:999}
#xx2menu,#xx2menu ul{list-style:none;}
#xx2menu{float:left;font-family:Arial;}
#xx2menu > li{float: left;position: relative;}
#xx2menu li a{display:block;padding:11px 10px 12px 10px;text-decoration:none;}
#xx2menu ul {position:absolute;display:none;z-index:999;}
#xx2menu ul li a{width:80px;}
#xx2menu li:hover ul{display: block;}
#xx2menu > li > a{color: #fff;font-weight:700;}
#xx2menu > li:hover > a{background: #EAD593;color: #000;}
#xx2menu ul{border-bottom-right-radius:3px;border-bottom-left-radius:3px}
#xx2menu ul li a{color:#000;}
#xx2menu ul li:hover a{background: #ffc97c;}
span.badge{
display:inline-block;
padding: 1px 5px 1px 5px;
text-align:center;
color:#fff !important;
font-size:10px;
line-height:13px;
/*-webkit-border-radius:3px;*/
-moz-border-radius:3px;
border-radius:3px;
-o-border-radius:3px;
-khtml-border-radius:3px;
}
a span.badge{
position: absolute;
top: -4px;
right: 0px;
margin: 0;
}
span.badge.on{
background-color:#f60;
color: #ffffff !important;
}
.lsub:nth-child(odd){background-color:#EFDEAB}
.lsub:nth-child(even){background-color:#EAD593;}
<div id="xx2menus">
<ul id="xx2menu">
<li>One</li>
<li>Two<span class="badge on">5</span></li>
<li>Three</li>
<li>Four<span class="badge on">17</span>
<ul>
<li class="lsub">Submenu1</li>
<li class="lsub">Submenu2</li>
</ul>
</li>
</ul>
</div>

Second level submenu CSS

I was hoping if you can help me with my little problem. I am just updating one of my developers style sheets. I am a beginner in CSS so I am having difficulties adding the second level submenu in it.
Here's the link DEMO PAGE
This is my HTML
<div id="sidebar"><i class="icon icon-home"> </i>Dashboard<ul style="display: block;">
<li class="active"><i class="icon icon-home"></i> <span>Dashboard</span> </li>
<li> <i class="icon icon-signal"></i> <span>Charts & graphs</span> </li>
<li><i class="icon icon-th"></i> <span>Tables</span></li>
<li><i class="icon icon-fullscreen"></i> <span>Full width</span></li>
<li class="submenu"> <i class="icon icon-th-list"></i> <span>API</span> <span class="label label-important">4</span>
<ul>
<li>
boom
<ul>
</ul>
</li>
<li>% of National Roads Paved</li>
<li>Process</li>
<li>Regional Profiles</li>
</ul>
</li>
</ul>
</div>
and this is my CSS
/* Top user navigation */
#sidebar{ width:100%; background:#252125; position:absolute; clear:both; top:62px;}
#sidebar > ul{ margin:0px; padding:0px; width:100%; display:block; z-index:999;}
/*Border right sidebar */
#sidebar > ul > li { list-style-type:none; float:left; display:block; margin:0px; border-right:1px solid #464652; position:relative; padding:10px; cursor:pointer}
/*Border right */
#sidebar > ul > li a{ padding:12px 0;}
#sidebar > ul > li:hover ul { display:block;}
/*#sidebar > ul > li:hover { background-color:#41bedd;} */
/*On hover menu */
#sidebar > ul > li:hover { background-color:#464652;}
/*On hover menu */
#sidebar > ul > li:hover a{ background:none;}
/*Modules color */
#sidebar > ul li ul { margin:0px; padding:0px; display:none; z-index:999; position:absolute; left:0px; top:40px; background:#464652; min-width:200px;}
/*Modules color */
#sidebar > ul li ul li { list-style-type:none; margin:0px; font-size:12px;line-height:30px; }
#sidebar > ul li ul li a { display:block; padding:5px 10px; color:#fff; text-decoration:none; font-weight:bold; }
/*Modules color on hover */
#sidebar > ul li ul li:hover a{ background-color:#5A5A69;}
/*Modules color on hover*/
#sidebar > ul li span { cursor:pointer; margin:0px 2px 0 5px; font-weight:bold; color:#fff; font-size:11px; }
#sidebar > ul li a i{ background-image: url("../img/glyphicons-halflings-white.png"); margin-top:4px; vertical-align: top;}
I know this post has been posted from different threads. I really cant understand them. Hope you understand. Thanks in advance.
First of all, in your sample HTML, you don't have any lis in your tertiary level. Put some in there.
As for your CSS, it's presently set up to handle the showing and hiding of UL's below the top level one on hover. We need to get more specific so that it excludes the 3rd level--as well as then get more specific to and add a second level hover style.
Where you have this:
#sidebar > ul > li:hover ul { display:block;}
Change it to this:
#sidebar > ul > li:hover > ul { display:block;}
The first will show ALL child ULs of the LI on hover. The latter will show only the direct child of the LI on hover.
Now we need to add a trigger for the 3rd level:
#sidebar > ul > li > ul > li:hover > ul { display:block; top: 0; left: 200px}
While we're at it, we included a new set of positioning so that it appears to the right of the current hover rather than below (which would cover up the second level navigation.
Working example: http://jsfiddle.net/wS9t3/

CSS Drop Down – Sub Menu Color

I'm looking for some advice on this issue.
I went through a tutorial a while back to build a CSS drop down menu and can't seem to change the default color of the sub menus – it always matches the default red color for the a tag.
I've been messing around with this for a while now and can't seem to find a solution. Can someone help me out with this please?
Here is the html:
<nav>
<ul>
<li><a class="selected" href="index.html">Home</a></li>
<li>Clothing</li>
<li>Gear</li>
<li>Brand
<ul>
<li>XXXXXX</li>
<li>XXXXXX</li>
</ul>
</li>
<li>Fighters
<ul>
<li>XXXXXX</li>
<li>XXXXXX</li>
</ul>
</li>
<li>My Account</li>
</ul>
</nav>
And here is the CSS:
nav {
position:relative;
float:right;
font-size:14px;
margin-top:35px;
font-weight:bold;
padding-right:178px;
z-index:4;
}
nav ul ul {
display:none; /* hide sub menus */
}
nav ul li:hover > ul {
display:block; /* show sub menus on hover */
}
nav ul {
float:right;
font-size:14px;
margin-top:-3px;
text-transform:uppercase;
list-style:none;
position:relative; /* position sub menu according to nav */
display:inline-table; /* condense with of sub menu to fit */
}
nav ul:after {
content:"";
clear:both;
display:block; /* clear floats on other list items */
}
nav ul li {
float:left;
}
nav ul li:hover a {
color:#ee1f3b;
text-decoration:none;
-webkit-transition-property:color;
-webkit-transition-duration:0.2s, 0.2s;
-webkit-transition-timing-function:linear, ease-in;
-moz-transition-property:color;
-moz-transition-duration:0.2s, 0.2s;
-moz-transition-timing-function:linear, ease-in;
}
nav ul li a {
padding:4px 11px;
text-decoration:none;
color:#000000;
display:block;
text-decoration:none;
}
nav ul ul {
background:#cacaca;
position:absolute;
top:25px; /* sub position */
}
nav ul ul li {
float:none;
border-bottom:1px solid rgba(0, 0, 0, 0.2);
position:relative;
}
nav ul ul li:last-child {
border-bottom:1px solid rgba(0, 0, 0, 0.2);
}
.selected {
color:#ee1f3b;
}
nav ul ul li a:hover {
color:#000000;
}
Thanks for your time.
From the above code for changing the color of submenus, you have not targeted the child elements of the main menus. For that you need to target them and add new rules to specifically target that element and change the color. Here is the solution.
On hover of the items with submenus, the color change for instance here green color on display of the submenus.
nav ul li:hover ul li a{color:green;}
On hover of the submenus, change of color from green to yellow for instance.
nav ul li:hover ul li a:hover{color:yellow;}
To elaborate this,
The HTML:
<nav>
<ul>
<li><a class="selected" href="index.html">Home</a></li>
<li>Clothing</li>
<li>Gear</li>
<li>Brand
<ul>
<li>XXXXXX</li>
<li>XXXXXX</li>
</ul>
</li>
<li>Fighters
<ul>
<li>XXXXXX</li>
<li>XXXXXX</li>
</ul>
</li>
<li>My Account</li>
</ul>
</nav>
The CSS:
nav {
position:relative;
float:right;
font-size:14px;
margin-top:35px;
font-weight:bold;
padding-right:178px;
z-index:4;
}
nav ul ul {
display:none; /* hide sub menus */
}
nav ul li:hover > ul {
display:block; /* show sub menus on hover */
}
nav ul {
float:right;
font-size:14px;
margin-top:-3px;
text-transform:uppercase;
list-style:none;
position:relative; /* position sub menu according to nav */
display:inline-table; /* condense with of sub menu to fit */
}
nav ul:after {
content:"";
clear:both;
display:block; /* clear floats on other list items */
}
nav ul li {
float:left;
}
nav ul li:hover a {
color:#ee1f3b;
text-decoration:none;
-webkit-transition-property:color;
-webkit-transition-duration:0.2s, 0.2s;
-webkit-transition-timing-function:linear, ease-in;
-moz-transition-property:color;
-moz-transition-duration:0.2s, 0.2s;
-moz-transition-timing-function:linear, ease-in;
}
nav ul li a {
padding:4px 11px;
text-decoration:none;
color:#000000;
display:block;
text-decoration:none;
}
nav ul ul {
background:#cacaca;
position:absolute;
top:25px; /* sub position */
}
nav ul ul li {
float:none;
border-bottom:1px solid rgba(0, 0, 0, 0.2);
position:relative;
}
nav ul ul li:last-child {
border-bottom:1px solid rgba(0, 0, 0, 0.2);
}
.selected {
color:#ee1f3b;
}
nav ul ul li a:hover {
color:#000000;
}
nav ul li:hover ul li a{color:green;}
nav ul li:hover ul li a:hover{color:yellow;}
Hope this helps.
Another method is to give the ul a id in the submenu something like this
<li>Brand
<ul id="submenu">
<li>AAAAAA</li>
<li>BBBBBB</li>
</ul>
</li>
CSS
#submenu li a
{
color:green;
}
See the full Jsfiddle here

Nav bar submenu container: How to cope with long list-item overflow by wrapping?

I have a hosted blog and I'm modifying templates, however the code for adding submenus to the nav bar is straight out of this great tutorial:
http://www.devinrolsen.com/pure-css-horizontal-menu/
I also read this answer to the question on Stackoverflow http://bit.ly/16KQN0M
But if it's a matter of clearing a float, I can't see where to put "clear: both;" in the HTML (at least, nothing I've tried has worked).
And changing #dropnav li li to display: block; doesn't work either. There must be something I'm missing ...
Here is the CSS. The classes at the top are related to the template but I'll leave them in as they might be relevant.
<style type="text/css">
/* Derived from http://www.devinrolsen.com/pure-css-horizontal-menu/ */
#pagebody { position: inherit !important; width: 100%; }
#pagebody-inner { position: inherit !important; width: 100%; }
#alpha, #beta, #gamma, #delta {
display: inline;
position: inherit !important;
float: left;
min-height: 0px;
}
#dropnav
{height:31px;}
#dropnav ul
{margin:0px; padding:0px;}
#dropnav ul li
{display:inline; float:left; list-style:none; position: relative; height:31px;
width: 175px; }
#dropnav li a
{color:#efe1ca; font-family:'Roboto Condensed', sans-serif; font-weight:400;
font-size:12px; }
#dropnav li a:hover
{color:#fff; text-decoration: none;}
#dropnav li ul
{margin: 0px; padding: 0px; display: none; position: absolute; z-index: 99; top:
31px; background-color: #f6f3cb; width: 250px;}
#dropnav li:hover ul
{display:block; width:250px; }
#dropnav li li
{list-style:none; display:list-item; font-size:100%;}
#dropnav li li a
{color: #7a3535; text-decoration:underline; width: 250px; font-size: 16px; }
#dropnav li li a:hover
{color:#000000; text-decoration:none; }
li#main {padding: 0px;} /* Sets the padding of items in the main menu */
</style>
And HTML markup, with titles removed:
<div id="main">
<div id="dropnav">
<ul>
<li class="nav-list-item">-------
<ul id="subnav">
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
<li style="width:180px;">-------</li>
</ul>
</li>
<li class="nav-list-item">-------
<ul id="subnav">
<li style="width:180px;">-------</li>
<li style="width:180px;"><a href="">-------</li>
</ul>
</li>
</ul>
</div>
</div>

Custom CSS menu, "Active" tab remains on 'Home' not the actual page

I created this custom css menu, but when switching tabs, the "Active" tab design remains on the 'Home' link on the menu, rather than the actual page I'm on. Any idea how I an fix this?
HTML :
<ul class="menu">
<li><span>Home</span></li>
<li><span>Testing post</span></li>
</ul>
CSS :
.menu {margin:0 auto; padding:0; height:30px; width:100%; display:block; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') repeat-x;}
.menu li {padding:0; margin:0; list-style:none; display:inline;}
.menu li a {float:left; padding-left:15px; display:block; color:rgb(255,255,255); text-decoration:none; font:12px Verdana, Arial, Helvetica, sans-serif; cursor:pointer; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 0px -30px no-repeat;}
.menu li a span {line-height:30px; float:left; display:block; padding-right:15px; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 100% -30px no-repeat;}
.menu li a:hover {background-position:0px -60px; color:rgb(255,255,255);}
.menu li a:hover span {background-position:100% -60px;}
.menu li a.active,
.menu li a.active:hover {line-height:30px; font:12px Verdana, Arial, Helvetica, sans-serif; background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 0px -90px no-repeat; color:rgb(255,255,255);}
.menu li a.active span,
.menu li a.active:hover span {background:url('http://media.datahc.com/Affiliates/43817/Brands/Image/topmenuimages.png') 100% -90px no-repeat;}
HTML:
<div class="menu">
<ul>
<li><a class="menuLink active" href="#">Home</a></li>
<li> <a class="menuLink" href="#">Page1</a></li>
<li><a class="menuLink" href="#">Page2</a></li>
<li><a class="menuLink" href="#">Page3</a></li>
</ul>
</div>
css:
.menu
{
height:64px;
width:100%;
background-repeat:repeat-x;
text-align:center;
}
.menuLink, .menuLink:visited
{
color:#00000;
background-image:url(img/btk.png);
text-decoration:none;
font-size: 20px;
width:70px;
height: 50px;
padding: 10px;
display:block;
margin-left: 10px;
margin-right: 10px;
margin-top: 6px;
}
.menuLink:hover
{
color:#CC7011;
background-color:aqua;
font-size: 26px;
}
.active{
background-color:aqua;
}
ul,li{
display:inline-block;
list-style:none;
line-height:60px;
vertical-align:bottom;
}
​
jquery:
$('.menuLink').click(function(){
$('a').removeClass('active');
$(this).addClass('active');
});​
Live Demo
http://jsfiddle.net/PYW35/
First you have an extraneous semicolon in in the first <li>
You need to move the class="active" to the <li> that you want to be active.
I don't know the exact answer to it but, I would say to find something that gets the url and if it matches the link in the bar then that would get class active, else, none are active.
I thing you need some JavaScript to get it done,
Here is the simple demo.
Hope this helps
Note : getElementsByClassName() not supported by some browsers
Take a look on the following comparison table

Resources