Does anyone know of a way with CSS to replicate the concept of alternating table row colors for each line within a sngle element?
Take for example : html
<table width="100%">
<tr>
<td bgcolor="#F4F4F4">Lingo 2 Port/ 2 Hour</td>
</tr>
<tr>
<td Lingo 2 Port/ 4 Hour</td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Lingo 4 Port/ 4 Hour</td>
</tr>
<tr>
<td>Replay 2 Port 18 Hour </td>
</tr>
<tr>
<td valign="TOP" bgcolor="#F4F4F4">Replay 4 Port 30 Hour</td>
</tr></table>
Now, obviuosly, you could create a different class for the colored rows and have a bunch of div tags. Pain though, code'y and if you have to add an item to the middle, it creates a mess for everything below it, especially if the list is like 40 items long.
What I wanna do is have a single element, where each line alternates in color. Take out or add an item, they all do their gig.
Any ideas?
Thanks,
JHI doubt it. I haven't ever seen anything like that in CSS. (But you can do it with Javascript, but there goes 13% of your visitors.) You might want to look into doing it server-side... Unless the table isn't server-generated (e.g., static).
JonaI'd probably create a <ul> with <li> having alternating class="color1" and class="color2".
The answer to your question is: No, you can't do it with any other techniqe.
Take for example : html
<table width="100%">
<tr>
<td bgcolor="#F4F4F4">Lingo 2 Port/ 2 Hour</td>
</tr>
<tr>
<td Lingo 2 Port/ 4 Hour</td>
</tr>
<tr>
<td bgcolor="#F4F4F4">Lingo 4 Port/ 4 Hour</td>
</tr>
<tr>
<td>Replay 2 Port 18 Hour </td>
</tr>
<tr>
<td valign="TOP" bgcolor="#F4F4F4">Replay 4 Port 30 Hour</td>
</tr></table>
Now, obviuosly, you could create a different class for the colored rows and have a bunch of div tags. Pain though, code'y and if you have to add an item to the middle, it creates a mess for everything below it, especially if the list is like 40 items long.
What I wanna do is have a single element, where each line alternates in color. Take out or add an item, they all do their gig.
Any ideas?
Thanks,
JHI doubt it. I haven't ever seen anything like that in CSS. (But you can do it with Javascript, but there goes 13% of your visitors.) You might want to look into doing it server-side... Unless the table isn't server-generated (e.g., static).
JonaI'd probably create a <ul> with <li> having alternating class="color1" and class="color2".
The answer to your question is: No, you can't do it with any other techniqe.