Using CSS to alternate colors

admin

Administrator
Staff member
Id like to do something with css so i can alternate the colors between two different things in something that looks like a table like on this site here.

<!-- m --><a class="postlink" href="http://tuneyard.com/index.phphttp://www.alistapart.com/articles/zebratables/thanks">http://tuneyard.com/index.phphttp://www ... les/thanks</a><!-- m --> sam.no problemi read in the article that you can use severside how would i do this? i guess like the forum does it.basically, you have a counter variable, and use the modulos operator, here's a php version:

<?php
$var=""; //an array of some sort
echo "<table>";
for($i=0;$i<count($var);$i++
{
if($i%2==0)
{
echo "<tr class=\"even\">";
}
else
{
echo "<tr class=\"odd\">";
}
}
?>
 
Back
Top