...

View Full Version : Using a class in a link



j05hr
12-08-2009, 09:50 AM
I know this should probably be better off in the PHP forum but it's also a css question so I'm posting it here.

Basically I have,



a:link, a:visited {
color: #fff; text-decoration:none;
}
a:hover, a:active {
color: #FFFFCC ; text-decoration:underline;
}


To make all my links go white, but I want this one link to be black, but it is in a PHP code and what I do for it isn't working.

This is what I've got.



$content .= '<a class="pageNumber" href="buying.php?pg=' . $i . '">' . $i . '</a>' . "&nbsp; ";
} else {
$content .= '<a class="pageNumber" href="buying.php?pg=' . $i . '">' . $i . '</a>' . "&nbsp; ";




.pageNumber a:link {
color: #000;
}

abduraooft
12-08-2009, 09:56 AM
.pageNumber a:link {
color: #000;
} That should be

a.pageNumber:link{
color: #000;
}

j05hr
12-08-2009, 10:04 AM
Didn't fix it, can you see anything else wrong with it? Here's the code from the source code of one of the links



<div id="result-data"><br><small style='font-size:11px;'>Found 6 listings</small><br><br><small style='font-size:11px;'>Pages: <a class="pageNumber" href="buying.php?pg=1">1</a>


And a link to the actual page, http://www.sampleestateagent.com/buying.php but if you want to see the links you have to click either 3, 6, 9 or 12 properties per page and then it's the page numbers that come up white that I want black

abduraooft
12-08-2009, 10:16 AM
but if you want to see the links you have to click either 3, 6, 9 or 12 properties per page and then it's the page numbers that come up white that I want black Can't you post a direct link? Or you may save your page as html from browser and upload it to a new location along with the linked stylesheet. (Sorry, I don't get that highlighted part)

j05hr
12-08-2009, 10:22 AM
Hmm, you can't because the only link is the one i gave as it saves your search in your browser only,

what I mean is, if you go on the link and at the bottom, it says Number of Properties Per Page and for you to see the page numbers come up, you have to click one of the other options other than all (otherwise all the properties come up on one page)

abduraooft
12-08-2009, 10:26 AM
Pages: 1 2 3 4 5 6 That part is in black for in FF2, accepting the style
a.pageNumber:link {/*stylenew.css (line 32)*/
color:#000000;
} very well. Do a hard refresh (Ctrl+F5)/ clear the browser cache and check again.

j05hr
12-08-2009, 10:35 AM
I was clearing the cache thinking why isn't it working and it's because once you've clicked the link it makes it go white again which is the a:visited function.

How can I use visited in your code to make it stay the same colour?



a.pageNumber:link{
color: #000;
}

abduraooft
12-08-2009, 11:35 AM
a.pageNumber:link , a.pageNumber:visited{
color: #000;
}

j05hr
12-08-2009, 02:58 PM
What would be the best way to make my selected page be bold or a different colour?

I came up with this from google http://www.search-this.com/2007/06/13/css-current-page-indicator/ but the problem is that my links arn't usual links as they come from PHP.

I also thought this would work but doesn't, although it might be the way I wrote it.



a.pageNumber:hover, a.pageNumber:active {
color: #FFFFCC;
text-decoration:underline;
}


Is there any idea of how to highligt a link with CSS with this code


$content .= "<br><small style='font-size:11px;'> ";
for($i = 1; $i <= $pages; $i++) {
if($i == 1 && $i == $pages) {
$content .= $i;
}elseif($i == $pages) {
$content .= '<a class="pageNumber" href="buying.php?pg=' . $i . '">' . $i . '</a>' . "&nbsp; ";
} else {
$content .= '<a class="pageNumber" href="buying.php?pg=' . $i . '">' . $i . '</a>' . "&nbsp; ";
}
}
$content .= "</small><br>";

abduraooft
12-08-2009, 03:03 PM
What would be the best way to make my selected page be bold or a different colour? I prefer the method given at http://www.codingforums.com/showpost.php?p=605564&postcount=3

j05hr
12-08-2009, 03:15 PM
Buy my pages don't have links like



<ul id="nav">
<li id="nav_home"><a href="#">home</a></li>
<li id="nav_about"><a href="#">about</a></li>
<li id="nav_contact"><a href="#">contact</a></li>
</ul>


It's done in PHP so you don't see every individual link like that.

abduraooft
12-08-2009, 03:21 PM
You could device a logic to dynamically apply different class/id to those links.

j05hr
12-08-2009, 03:23 PM
Any chance you giving me a clue on how to start the logic?

abduraooft
12-08-2009, 03:38 PM
Ah.. wait. They are links from a pagination system, right? So, why do you need to display the selected items as a link? Just echo that number when the selection is on that page, otherwise show the link.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum