Forum Moderators: not2easy

Message Too Old, No Replies

active link

         

php_member

8:49 pm on May 12, 2009 (gmt 0)

10+ Year Member



I have one beginner question. How to keep a style for active link also when you click out? It works now in a way that it shows style for active when I click on the link, but when I leave the click it turns again to normal style.

Is the only way to do this to make if statement? like this:
if ($_SERVER['PHP_SELF'])=="/inbox.php") {echo "font-weight: bold;";}

Thank you

simonuk

12:18 pm on May 13, 2009 (gmt 0)

10+ Year Member



You would create a class for a:hover and also a class for the active link. As an example:

#menu a:hover, .active {background-color:tan;}

Then if they user hovered or clicked the link as long as the new page navigation used the .active class it would remain the same.

php_member

5:22 pm on May 13, 2009 (gmt 0)

10+ Year Member



I did like you said, but still nothing. Below is my code. Do you have any idea what is wrong? tnx

a.inbox:link {color: #666666; text-decoration: underline; font-family: arial; font-size: 17px;}
a.inbox:visited {color: #666666; text-decoration: underline; font-family: arial; font-size: 17px;}
a.inbox:hover {color: #666666; font-weight: bold; text-decoration: none; font-family: arial; font-size: 17px;}
a.inbox:active {color: #666666; font-weight: bold; text-decoration: none; font-family: arial; font-size: 17px;}

<div id="newmessages">
<a class="inbox" href="<?php echo $_SERVER['PHP_SELF']."?p=new" ?>">New messages</a>
</div>
<div id="alreadychecked">
<a class="inbox" href="<?php echo $_SERVER['PHP_SELF']."?p=read" ?>">Already checked</a>
</div>
<div id="sent">
<a class="inbox" href="<?php echo $_SERVER['PHP_SELF']."?p=send" ?>">Sent</a>
</div>
<div id="newmessage">
<a class="inbox" href="<?php echo $_SERVER['PHP_SELF']."?p=write" ?>">Write a message</a>
</div>

DrDoc

7:48 pm on May 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld!

I have a feeling you mean something completely different by

active
than what it actually does.

An

active
link is only
active
while it is being clicked. It has nothing to do with the page you are currently on. For that, throw another little PHP snippet on that adds a secondary class:
current
. Then style that differently.

php_member

10:49 pm on May 13, 2009 (gmt 0)

10+ Year Member



Thank you, I misunderstood the meaning of active.