This is a discussion on "CSS Active Links" within the Web Page Design section. This forum, and the thread "CSS Active Links are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
CSS Active Links
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
CSS Active Links
Hi guys,
I want to create a menu that is going to be called from an include file. The problem is i want the link to appear differently when you are on that page. So for example if you are on the home page the homepage button will be blue and the rest of the buttons will be grey. Is it possible in CSS to set an active link to a different colour? (i have tried the a:active but thats just for mousedown isnt it?) I would also like the current link to be inactive so you cant select it - is this also possible? thanks john |
|
|
|
||||
|
Re: CSS Active Links
Not sure how this would work with an include but.
Set an id or class for it. #foo li#current a {} etc... <li id="current"><a href="" title="">Foo!</a></li>
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Last edited by moojoo; Aug 11th, 2006 at 20:08. |
|
|||
|
Re: CSS Active Links
How is your JavaScript coding? I do what you want to do on my web sites but rather than just drop the answer in your lap, so to speak, I'll give you some pointers. That way you learn more. Give each of your links a unique id. Create a css style to be used with the inactive link. Use a meta tag to give each page an identifier. Write some JavaScript that runs 'onload' which searches your navigation for a link id that fits with the page identifier. Then use JavaScript to replace the a link with a span and asign the css style for the inactive link. |
|
|||
|
Re: CSS Active Links
Hi Geoff, my JavaScript knowledge is ok, not very good at writing from scratch but I can modify code to get it to do what i want... usually ;-)
I have actually found some code now on a forum and modified it to suit what i wanted...ish:
Here is a link so you can see what i mean http://www.2percentinspiration.com/R...io_rapport.asp What i want is for the nav to stay highlighted even if your on one of the sub pages (e.g -2.asp or -3.asp) OR (Ideally) For the content to change within the same document rather than going to different pages - but have no idea how to achieve this Hope this makes sense? thanks J |
|
|||
|
Re: CSS Active Links
This is beyond simple... way over thinking it here.
As been said, have a unique id for each link. On the page itself, add a style for the specific ID of that page link to make it appear how you want. There is nothing wrong with having specific styles defined within a page.
|
|
||||
|
Re: CSS Active Links
Yeah giving each link an id would be the simplest way
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
![]() |
| Tags |
| css, active, links |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| active active X | R8515198 | Flash & Multimedia Forum | 11 | May 18th, 2007 02:50 |
| How do I get people active and keep them active? | TheSealPortalTeam | Webforumz Cafe | 4 | May 9th, 2007 10:17 |
| Active State | Lchad | Web Page Design | 10 | Jan 27th, 2007 01:29 |
| CSS - a:active | ruffy | Web Page Design | 3 | Nov 2nd, 2006 08:50 |
| active x problem | dbarrie | Web Page Design | 3 | Jul 19th, 2006 16:32 |