Changing Alternate Color in Table TR
$k = 0;
$style[0] = "odd_class";
$style[1] ="even_class";
for ($i = 1; $i <= 10; $i++) {
$k= 1 - $k;
$rowStyle = $style[$k];
echo 'class="'. $rowStyle . '"';
}
CSS3 Zebra Striping a Table
tbody tr:nth-child(odd) {
background-color: #ccc;
}
Applying Even/Odd Classes in PHP
<style>.box{width: 20px; height: 10px; }
.class0{ background-color: red; }
.class1{ background-color: blue; }
.class2{ background-color: green;}
.class3{background-color: yellow;}
</style>
<?php $xyz =0; $abc=0;
for ($i=0; $i < 2000; $i++) { ?>
<div id="<?php echo $i; ?>" class="box class<?php echo ($abc++%4); ?>" ></div>
<?php } ?>
No comments:
Post a Comment