/    Sign up×
Community /Pin to ProfileBookmark

Using CSS to alternate colors

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.

[url]http://tuneyard.com/index.php[/url]

to post a comment
CSS

5 Comments(s)

Copy linkTweet thisAlerts:
@ConorauthorMar 22.2004 — thanks sam.
Copy linkTweet thisAlerts:
@SamMar 22.2004 — no problem
Copy linkTweet thisAlerts:
@ConorauthorMar 24.2004 — i read in the article that you can use severside how would i do this? i guess like the forum does it.
Copy linkTweet thisAlerts:
@SamMar 24.2004 — basically, you have a counter variable, and use the modulos operator, here's a php version:
[code=php]
<?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">";
}
}
?>
[/code]
×

Success!

Help @Conor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...