current page style...? |
current page style...? |
Jul 20 2009, 09:37 AM
Post
#1
|
|
![]() Senior Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Official Designer Posts: 5,880 Joined: Nov 2007 Member No: 593,382 |
I have seen on some sites, when you click on a nav link when you go the page, that link stays, highlighted or something signifying that you are still on that page. How do you do that? I thought you just used "a:active"? But im trying it out and it isnt working.
|
|
|
|
![]() |
Jul 20 2009, 10:14 PM
Post
#2
|
|
|
Senior Member ![]() ![]() ![]() ![]() ![]() ![]() Group: Member Posts: 1,237 Joined: May 2008 Member No: 648,123 |
You could use if statements and use CSS to style the "current" class:
CODE <ul> <li><a<?php if($page == 'link-1') echo ' class="current"'; ?> href="#">Link 1</a></li> <li><a<?php if($page == 'link-2') echo ' class="current"'; ?> href="#">Link 2</a></li> <li><a<?php if($page == 'link-3') echo ' class="current"'; ?> href="#">Link 3</a></li> </ul> Of course, you'll just need to define what the variable $page is. If you have links like yoursite.com/link-1.php, you can get the file name and use that: CODE <?php $page = $_SERVER['SCRIPT_FILENAME']; $page = explode('.php', $page); $page = $page[0]; ?> In this case, going to yoursite.com/link-1.php, $page is link-1. |
|
|
|
jcp current page style...? Jul 20 2009, 09:37 AM
jcp No mean like I have seen pages that the nav links ... Jul 20 2009, 11:52 AM
schizo They probably have a slightly different stylesheet... Jul 20 2009, 11:54 AM
Mikeplyts You could also just try making a custom class/id f... Jul 20 2009, 11:55 AM
Mikeplyts ^basically what I just said. Jul 20 2009, 12:04 PM
Mikeplyts Oh, haha. Jul 20 2009, 01:01 PM
tcunningham if you are using a list for links, try #(ID) a:act... Jul 20 2009, 01:12 PM
jcp Is that how cb does it? I was just hoping there wa... Jul 20 2009, 08:51 PM
theerinkal I got told about this website. I think it's pr... Jul 20 2009, 10:23 PM
HeartOfPandora You can do it with a teeny bit of PHP and some CSS... Jul 20 2009, 10:53 PM
mipadi In most cases, it's probably just a simple bit... Jul 21 2009, 01:41 PM![]() ![]() |