Log In · Register

 
 
Closed TopicStart new topic
current page style...?
Maccabee
post 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.
 
Maccabee
post Jul 20 2009, 11:52 AM
Post #2


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



No mean like I have seen pages that the nav links are tabs and whichever page you are on the tab is raised. So you clock the contact link and then it knows you are on the contact page and gives a style to that link.
 
schizo
post Jul 20 2009, 11:54 AM
Post #3


Senior Member
******

Group: Staff Alumni
Posts: 2,435
Joined: Feb 2007
Member No: 506,205



They probably have a slightly different stylesheet on each page that has a an image of that page's link looking "raised."
 
Mikeplyts
post Jul 20 2009, 11:55 AM
Post #4


Mel Blanc was allergic to carrots.
*******

Group: Official Designer
Posts: 6,371
Joined: Aug 2008
Member No: 676,291



You could also just try making a custom class/id for the link that will mark what current page it is and then you can just apply that class/id to that certain link in the navigation according to what page it marks. shrug.gif
 
Mikeplyts
post Jul 20 2009, 12:04 PM
Post #5


Mel Blanc was allergic to carrots.
*******

Group: Official Designer
Posts: 6,371
Joined: Aug 2008
Member No: 676,291



^basically what I just said. mellow.gif
 
Mikeplyts
post Jul 20 2009, 01:01 PM
Post #6


Mel Blanc was allergic to carrots.
*******

Group: Official Designer
Posts: 6,371
Joined: Aug 2008
Member No: 676,291



Oh, haha.
 
synapse
post Jul 20 2009, 01:12 PM
Post #7


Live long and prosper.
********

Group: Staff Alumni
Posts: 10,142
Joined: Apr 2007
Member No: 514,926



if you are using a list for links, try #(ID) a:active in your html/xhtml markup.

example:
CODE
<ul id="navigation">
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 2</a></li>
  <li><a href="#">Link 3</a></li>
</ul>

CODE
#navigation { color:#ff0000; }
#navigation a:active{ color:#ff00ff; }
 
Maccabee
post Jul 20 2009, 08:51 PM
Post #8


Senior Member
*******

Group: Official Designer
Posts: 5,880
Joined: Nov 2007
Member No: 593,382



Is that how cb does it? I was just hoping there was a way to do it in css, cause when I make sites everything is exactly the same on every page, since I use the includes. I guess I need to stop doing that.
Like this:
<?php include("includes/header.php"); ?>
Homepage
<?php include("includes/footer.php"); ?>

 
fixtatik
post Jul 20 2009, 10:14 PM
Post #9


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.
 
theerinkal
post Jul 20 2009, 10:23 PM
Post #10


Irrisistable Cabbages.
*****

Group: Member
Posts: 549
Joined: Nov 2007
Member No: 589,355



I got told about this website. I think it's pretty nice. You have to click page source to get some of the codes but other than that, I use it.

That is ALL CSS, no javascript or anything comes with those.
 
HeartOfPandora
post Jul 20 2009, 10:53 PM
Post #11


i like boobies, yes I do. I like boobies - how 'bout you?
*****

Group: Member
Posts: 620
Joined: Jun 2008
Member No: 662,457



You can do it with a teeny bit of PHP and some CSS styling, but I don't know the snippet and I can't remember how to find it... :x
 
mipadi
post Jul 21 2009, 01:41 PM
Post #12


Senior Member
******

Group: Administrator
Posts: 2,648
Joined: Apr 2008
Member No: 639,265



In most cases, it's probably just a simple bit of server-side logic, like so:

CODE
<a href="link.html"{% if currentpage %} class="currentpage"{% endif %}</a>


And then you just style a.currentpage using CSS.
 

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: