Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-13-2012, 03:09 PM   PM User | #1
huhnej31
New to the CF scene

 
Join Date: Dec 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
huhnej31 is an unknown quantity at this point
Navigation Menu: a:hover styling works, a.selected does not

Hello,

I have a simple navigation bar that I would like to change color over hover and remain that color when selected. The a:hover works great but the a.selected does not (even though the class="selected" does work for each individual page) This is how I have the list set up:

Code:
<ul id="kids_nav">
<li><a class="selected'" id="maggie" href="http://asdf.com">Maggie</a></li>
<li><a class="" id="dijon" href="http://agsdf.com">Dijon</a></li>
<li><a class="" id="brandon"href="http://asdsdf.com">Brandon</a> </li>
<li><a class="" id=""href="asdfg.com">Behind The Scenes</a></li>
</ul>
And here is most of my CSS so you can get the idea...

Code:
#kids_nav li a{
	
	font-size: 1.5em;
	font-weight: bold;
	color: #373737;
	padding: 5px;
	padding-left: 15px;
	padding-right: 15px;
}
#kids_nav li a#dijon{
	color: #00763f;
}

#kids_nav li a#dijon:hover, #kids_nav li a#dijon.selected{
	background-color: #00763f;
	color: #fff;
}

#kids_nav li a#brandon{
	color: #CD5400;
}

#kids_nav li a#brandon:hover, #kids_nav li a#brandon.selected{
	background-color: #CD5400;
	color: #fff;
}
Any advice would be great! Like I said, the class=selected works on all of the pages, the hover works, but I just cant get the items to remain highlighted. Thank you in advance!
huhnej31 is offline   Reply With Quote
Old 12-14-2012, 05:44 AM   PM User | #2
vjm
New Coder

 
Join Date: Nov 2012
Location: PH
Posts: 16
Thanks: 1
Thanked 2 Times in 2 Posts
vjm is an unknown quantity at this point
if the class="selected" works on all of the pages, in what exact area it doesn't work? I'm confused.
vjm is offline   Reply With Quote
Old 12-14-2012, 08:41 AM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello huhnej31,
#maggie.selected isn't right.
Try it like this instead -
Code:
#kids_nav li a#maggie:hover, .selected{
	background-color: #00763f;
	color: #fff;
}
You class selected has an extra ' in your markup that is screwing things up as well.



Here's another way of highlighting a menu item to show where you are.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

Last edited by Excavator; 12-14-2012 at 08:45 AM..
Excavator is offline   Reply With Quote
Old 12-14-2012, 10:05 AM   PM User | #4
webdevs
New Coder

 
Join Date: Nov 2012
Location: India
Posts: 52
Thanks: 0
Thanked 3 Times in 3 Posts
webdevs is an unknown quantity at this point
Its easy to give hover text or background colour using CSS. give perticuler background colour or text colour on mouse hover class.
webdevs is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:16 PM.


Advertisement
Log in to turn off these ads.