Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS selected menu problem 2

Status
Not open for further replies.

Robo82

Programmer
May 13, 2008
2
GB
Hi all

I have a problem in IE6, I have a vertical menu and when the user hovers over it the selected menu item changes colour and once selected stays that colour.

However in IE6 when the page is loaded the colour is already applied to the menu items(all of them).

Can anyone see my error?
Code:
#SideNav{
	width: 180px;
	margin-top: 10px;
	float: left;
	margin-right: 10px;
}
#SideNav p{
	color: #598D98;
	font-weight: bold;
	margin-bottom: 5px;
}
#SideNav ul{
	list-style: none;
	margin: 0 0 0 -5px;
	padding: 0;
}
#SideNav ul li{
	width: 100%;
}
#SideNav ul li a{
	color: #666;
	height: 15px;
	width: 180px;
	text-decoration: none;
	font-weight: normal;
	background-color: #FFF;
	display:block;
	padding: 5px;
}
#SideNav ul li a:hover, #SideNav ul li a.selected{
	color: #FFF;
	height: 15px;
	width: 180px;
	text-decoration: none;
	font-weight:bold;
	display:block;
	padding: 5px;
}
#SideNav ul li a:hover.Blue, #SideNav ul li a.selected.Blue{
	background-color: #3399FF;
}
#SideNav ul li a:hover.Green, #SideNav ul li a.selected.Green{
	background-color: #4BB47A;
}
#SideNav ul li a:hover.Orange, #SideNav ul li a.selected.Orange{
	background-color: #CE9638;
}
#SideNav ul li a:hover.Orange2, #SideNav ul li a.selected.Orange2{
	background-color: #B86C48;
}
#SideNav ul li a:hover.Pink, #SideNav ul li a.selected.Pink{
	background-color: #B82A59;
}
#SideNav ul li a:hover.Purple, #SideNav ul li a.selected.Purple{
	background-color: #94779F;
}
#SideNav ul li a:hover.Default, #SideNav ul li a.selected.Default{
	background-color: #598D9A;
}
 
Yes - it's your use of multiple classnames in your rules. IE 6 has a known bug with this where it applies the rule if ANY of the classnames match. So, this rule:

Code:
a.selected.Default

would match either:

Code:
<a class="selected">

or

Code:
<a class="Default">

or

Code:
<a class="selected Default">

Unfortunately, this means you'll have to deliver unique classnames to get around this.

IE 6 sucks, doesn't it?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Where you have used this:
Code:
#SideNav ul li a:hover.Blue
I would suggest changing it to:
Code:
#SideNav ul li a.Blue:hover
It could also be something to do with IE getting confused with multiple classes on the same element. As it tends to do.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
thanks Dan, I had a feeling it would be something like that.

You've saved me a lot of searching
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top