• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

CSS to color code every other line?

Rogue

Banned
Does anyone know of a way to systematically color code every other row in a table using a style sheet property? Reason I ask is that we have a page that pulls data off of another server into a table. I have to use style sheets to apply the desired effect because otherwise it uses default browser settings for text, etc. I want something that will color code every other row a different shade to make reading the data easier. Thanks for any help you can provide.
 
What you are using for serverside processing is important, but only in the details...

you'll want a loop and then some counter (such as 'i') to indicate which record number you are on...

then do something like this:

String sColor = "DEFAULT" ;
if ( i%2 != 0 )
sColor = "RED";

String sSSheet = "ROW-" + color ;

Your style sheet will have two styles defined, for example:
.ROW-DEFAULT { etc }
.ROW-RED { etc }

I am sure you can figure it out from there. Makes sense?
 
See, the thing is, the data is pulled off of a CMS server (Call Management Sytem) and written as a basic black and white table using a proprietary tag that I insert into a template at the point where I want the data inserted. There's no way to format it prior to it being written to the web server and formatting it afterward would be a lot of work. The table is very, very basic in it's format...

<table>
<tr>
<td></td>
</tr>
</table>

So what I've done is applied properties to the basic HTML tags for the other things I want to format (ie.- font size, color, etc). I want to find a way to use CSS and the <tr> tag (with no HTML properties applied) and loop through the data inserted by the server, after it's inserted. Can I do something like an IF/THEN loop in conjunction with a style sheet property for the TR tag?
 
Back
Top