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 11-29-2011, 04:24 AM   PM User | #1
kimmi_baby
New Coder

 
Join Date: Jun 2010
Posts: 46
Thanks: 10
Thanked 0 Times in 0 Posts
kimmi_baby is an unknown quantity at this point
How to show the current active link

Hi,

I was wondering how to show the current active link on the navigation?

I also have a few tables that I need to show the active link on as well.

Thanks
kimmi_baby is offline   Reply With Quote
Old 11-29-2011, 04:40 AM   PM User | #2
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 kimmi_baby,
Have a look at this example - http://nopeople.com/CSS%20tips/h_ul_...ges/index.html
__________________
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
Excavator is offline   Reply With Quote
Old 11-29-2011, 06:55 AM   PM User | #3
kimmi_baby
New Coder

 
Join Date: Jun 2010
Posts: 46
Thanks: 10
Thanked 0 Times in 0 Posts
kimmi_baby is an unknown quantity at this point
Thank you for your reply

Now I'm a little bit confused on a few thing...

What if at the moment my CSS looks like this:

Code:
#nav li#nav-home a {
width:101px;
height:20px;
background:url(../images/main%20menu%20tabs/nav_home.png) no-repeat;/* X and Y position at 0 */
}


#nav li#nav-home a:hover {
width:101px;
height:20px;
background:url(../images/main%20menu%20tabs/nav_home.png) no-repeat;
background-position: 0 -20px;

}

Do I need to rewrite all of it for the ID to work?
kimmi_baby is offline   Reply With Quote
Old 11-29-2011, 07:11 AM   PM User | #4
kimmi_baby
New Coder

 
Join Date: Jun 2010
Posts: 46
Thanks: 10
Thanked 0 Times in 0 Posts
kimmi_baby is an unknown quantity at this point
What if I have more than one stylesheet?
kimmi_baby is offline   Reply With Quote
Old 11-29-2011, 03:29 PM   PM User | #5
kishanvaja
New to the CF scene

 
Join Date: Nov 2011
Location: Milton Keynes, UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
kishanvaja is an unknown quantity at this point
I managed this by giving the body an ID (page name such as home, contact-us etc.). Then in my nav I gave the "a href" a class which matched the body ID.

My CSS then looked like this:-
Code:
#home .home, #contact-us .contact-us {
	background-color: #000;
	background-repeat: no-repeat;
	background-position: left top;
}
The only thing you need to change on a page by page basis is the Body ID as all your nav links are classed up. I also run multiple stylesheets and it's no problem.
kishanvaja is offline   Reply With Quote
Old 11-29-2011, 03:30 PM   PM User | #6
kishanvaja
New to the CF scene

 
Join Date: Nov 2011
Location: Milton Keynes, UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
kishanvaja is an unknown quantity at this point
Sorry forgot to include code for the HTML
Code:
<body id=brighton>
... a little bit later...
<ul>
<li><a href="../birmingham/index.html" class="birmingham" accesskey="1" title="">Birmingham</a></li>
<li><a href="../brighton/index.html" class="brighton" accesskey="2" title="">Brighton</a></li>
<li><a href="../bristol/index.html" class="bristol" accesskey="3" title="">Bristol</a></li>
kishanvaja is offline   Reply With Quote
Old 11-29-2011, 04:10 PM   PM User | #7
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
Quote:
Originally Posted by kimmi_baby View Post

Do I need to rewrite all of it for the ID to work?
Each page will need a unique id. That should be the only change needed to your markup for this to work.

The beauty of this is there is no change made to the menu itself from page to page, you target the anchor from body id.
That makes it possible to use an include for your menu, something that you'll really appreciate later!
__________________
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
Excavator is offline   Reply With Quote
Old 11-29-2011, 04:11 PM   PM User | #8
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
I whipped out an example for you on your other thread since that's where the link to your page was.
__________________
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
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
kimmi_baby (11-30-2011)
Reply

Bookmarks

Tags
active link, css, html, table

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 07:57 AM.


Advertisement
Log in to turn off these ads.