Jump to content

Recommended Posts

Hi there,

 

I have quite a complex script and want to have the page that is currently active in my navigation a different color or class. I can do all the css, but wanted to know if there was an easy way to do this. Maybe I could just add a line on the index page to say use this class on the active navigation.

 

Is this possible?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/188717-change-colour-of-active-page-navigation/
Share on other sites

Just add an additional class attribute to your tag

 

<li class="active"><a href="index.php">Homepage</a></li>

 

And add the CSS:

 

.active a, a:active { background: #F00; color: #000; }

 

Yes, but he/she will still need to determine the active page.

Not if you use PHP you can easily determine the active page:

 

<li<?php print isActivePage($href, $_SERVER['REQUEST_URI']) ? ' class="active"' : ''; ?>><a href="<?php print $href; ?>"><?php print $label; ?></a></li>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.