| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| DesignersTalk > CSS - showing link as selected on particular page |
|
LinkBack | Thread Tools | Search this Thread |
|
|
#1 (permalink) |
|
PeaBee
Join Date: Dec 2004
Location: India
Posts: 63
|
CSS - showing link as selected on particular page
Hi, My problem is that I'm working on this huge site and I need to apply a certain style to the navigation. Will give you an example: Say I have 4 pages to the site - Home About Our Work Contact Now for this navigation, I have styles for active, hover, link and visited. The problem: If I'm on the page "About", how do I highlight that particular link? I have been doing this manually in the code by having a seperate style. I want to know how is it possible without adding anything manually to code. My site is huge and I can't possible go to each individual page to add the style. Please advise. It's pretty urgent!! |
|
|
|
|
|
#2 (permalink) |
|
div
|
just use some basic php - this article explains it all very simply. http://www.alistapart.com/articles/keepingcurrent/ I use it all the time |
|
|
|
#3 (permalink) |
|
PeaBee
Join Date: Dec 2004
Location: India
Posts: 63
|
How does one do this?
Hi there! Thanks for your super-fast reply! But I don't know a word of PHP. I am a pure design person :-( Take a look at this site: http://mambo.mamboforge.net/demo/ And see its CSS here: http://mambo.mamboforge.net/demo/tem...mplate_css.css I can't understand how they've gone about doing it. |
|
|
|
#4 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
If your site is static HTML pages, you'll need to do it manually. The only way to do it dynamically/automatically would be to use a scripting language like PHP. In other words, there's no way to do it with pure CSS, since CSS is static and what you want is for the site to "know" which page you're on without having to apply a class to the current page/link - that requires dynamic funtionality that's only provided by scripting languages like PHP. |
|
|
|
#6 (permalink) |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,202
|
no php needed. so you have 4 pages... Home About Our Work Contact You want to differentiate between them in your css so first off give them each a unique id in the body tag of your (x)html. For example, home page... <body id="home"> about page... <body id="about"> Right. Now you want to give each of your navigation links a unique id, so presuming you've used a list, you'd do... <ul> <li id="home-on"><a href="#">Home</a></li> <li id="about-on"><a href="#">About</a></li> <li id="work-on"><a href="#">Our Work</a></li> <li id="contact-on"><a href="#">Contact</a></li> </ul> And then in your css, to give the appearance say of bold text when you are on that particular page, you'd do... For the home page =============== #home #home-on a { font-weight: bold; } For the about page ================ #about #about-on a { font-weight: bold; } Geddit? |
|
|
|
#7 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
Yes, but I believe he said he had many pages. However, you make a good point that Home, About, Our Work, and Contact are only four pages and should only need 4 "current" states. The way I do it is the following... Code:
The CSS... Code:
Or however you need it to be. Just change the location of the 'class="current"' in the (X)HTML on each of the four pages...other pages will have no 'current' since you aren't at those pages anyway. That's how I do it, at least for static XHTML. |
|
|
|
#8 (permalink) |
|
now with added beard
Join Date: Mar 2004
Location: Liverpool
Posts: 5,549
|
I managed to get a site accidentally doing what he wants a while ago using just CSS - remembering the last clicked link and highlighting it (at least until you click on the page again) - but even when i go back to the same CSS it never seems to work for me again ??? Annoying ?? I should say so !! But it seems to be available here : http://css.maxdesign.com.au/listamat...izontal10.htm# fuck signatures
|
|
![]() |