交替表行背景颜色在动态表上 [英] Alternating table row background colors on a dynamic table

查看:132
本文介绍了交替表行背景颜色在动态表上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由 foreach 循环生成的表。

I have a table generated by a foreach loop.

在循环之前, $ c> $ iteration = 0 。在循环开始时,它增加 $ iteration

Before the loop, I create $iteration = 0. At the beginning of the loop it increments $iteration.

然后我这样做:

if($iteration % 2 == 0) { 
  $greyRow = 'css for a grey row'; 
}

我只有三行,

推荐答案

也许你也需要有一个 else 语句设置回奇数行上的其他颜色。如果没有看到更多的实现,就不太确定。

Perhaps you also need to have an else statement to set back to the other color on the odd rows. Not quite sure without seeing more of your implementation.

if ($iteration % 2 == 0) {
    $css = 'css for a grey row';
} else {
    $css = 'css for a white row';
}

这篇关于交替表行背景颜色在动态表上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆