中国开发网: 论坛: 程序员情感CBD: 贴子 697798
风无影: Zebra Striping with PHP (The Easy Way)
Using one of the built in Math functions of PHP we can easily create zebra striped lists.
Let's say we have an array of entries stored within the $comments variable.
All we have to do with this is to use the fmod function and assign a css class that alternates per entry.

<ul>
<?php foreach ($comments as $int => $comment): ?>
<li class="<?php echo fmod($int, 2) ? 'even' : 'odd' ?>">
<?php endforeach; ?>
</ul>

Then just give the even and odd classes different colours to suit your layout.

li.even {
background-color:#FFFFFF;
color:#000000;
}

li.odd {
background-color:#000000;
color:#FFFFFF;
}


And you're done!
CNDEV继续着,怎么也没人广播一下啊?

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录