I have text boxes, and when I start searching it displays result in table.
I am trying to implement a grid.
In this grid I have two colors so 1st row blue 2nd row green then it will come continuously for nxt rows 3rd row ii have blue and the next will be green.
How can I do that开发者_开发问答 ?
BY php
<table width="98%" border="0">
<tr>
<td> </td>
<td> </td>
</tr>
<?php
$i=1 while....
if($i%2==0)
{
$color = "color1";
}
else
{
$color = "color2";
}
?>
<tr bgcolor="<?php $color ?>">
<td> </td>
<td> </td>
</tr>
<?php $i++;
} // end while ?>
</table>
By css
tr:nth-child(even) {background: #CCC}
tr:nth-child(odd) {background: #FFF}
i think you looking for this
Compute oddity of your row index using modulo or bitwise AND and then apply some css class if odd/even.
精彩评论