|
| |
|
|
Avick
Posts: 181 From: Ireland Status: offline
|
Active Page when linking from Page includes - 9/6/2006 11:00:41
Just a question I have been curious about. When designing with style sheets is it possible to show a page as active if the link is coming from a page include. Example: Link 1 Link2 Link3 I want to change the style on Link2 when the visitor is on that page. As the pages are coming from a page include, I have nothing on the actual page to mark with a tag such as id=active Can this be done using just CSS or is it just out of the question!
_____________________________
Alan http://www.newebirl.net
|
|
|
|
Tailslide
Posts: 6003 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Active Page when linking from Page includes - 9/6/2006 11:33:36
Easiest thing to do is to assign an id to every page within the body element e.g. <body id="home"> Then in your include, add an id to every nav item like this: <ul>
<li><a href="whatever.html" id="nav-home">Home</a></li>
<li><a href="whatever1.html" id="nav-contact">Contact</a></li>
</ul> Then you can specify a rule within your stylesheet to apply only to the particular nav item id when you're on a page with a certain id like this:
#home #nav-home, #contact #nav-contact {font-weight:bold;}
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
Tailslide
Posts: 6003 Joined: 5/10/2005 From: Out here on the raggedy edge Status: offline
|
RE: Active Page when linking from Page includes - 9/6/2006 16:16:18
That sounds about right to me - it's all about specificity - the rules only apply when you've got both ids together on a page. That way you don't need to worry about trying to set up different classes on each active page - a single include with all your nav in it is all you need - just be sure that you give all the pages a specific id. The only thing I ever find is a problem is remembering to write out the CSS rule properly - bearing in mind that it can get quite long - inevitably I leave off a hash somewhere down the line!
_____________________________
"My strategy is so simple an idiot could have devised it" Little Blue Plane Web Design | Blood, Sweat & Rust - A Land Rover restoration project
|
|
|
|
Avick
Posts: 181 From: Ireland Status: offline
|
RE: Active Page when linking from Page includes - 9/7/2006 5:27:11
I now have two different sets of styles for two different types of menus I have been tinkering around with the layout to see if I could make it a bit easer to find what I am looking for when editing the tags. I stacked the tags on top of each other and it worked quite well and it validated.
#home #nav-home,
#portfolio #nav-portfolio,
#services #nav-services,
#standards #nav-standards,
#sitemap #nav-sitemap
{color: #006; border-bottom: 2px solid #006;}
I find this just makes it a little easer to read!
_____________________________
Alan http://www.newebirl.net
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|