Solved

Need to highlight menu item when page is active

Posted on 2013-05-30
3
411 Views
Last Modified: 2013-05-30
I am using php to include a menu on my individual pages which is a common practice. What I'd like to do is highlight the menu item when the corresponding page is active. I've tried a few methods but have been unsuccessful.

Any help is appreciated.
0
Comment
Question by:J C
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39208800
When a page is active, give the menu item that represents that page a different CSS class. Simply have two CSS rules in your stylesheet:  one for inactive tabs and the other for the active tabs. Just toggle between the classes as the pages change.
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 39208801
Just give each of the menu tabs a unique id, and then generate a style tag in the head with a single rule for the target id and the highlighting you want:
<style type="text/css">
#idnumber1 {background-color:magenta;}
</style>

Cd&
0
 

Author Closing Comment

by:J C
ID: 39209424
Thanks, that works.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will learn how to count occurrences of each item in an array.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question