本文介绍了如何调整交替表行的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道当动态获取内容时如何获得这种设计?我的意思是只有一个类,可以用于获取背景颜色,取决于块是奇数还是偶数。我希望我的要求是清楚的:背景颜色随行的奇数或偶数变化。
I was was just wondering how to get this kind of design done when things are fetched dynamically? I mean there has to be only one class which can be used to get the background colour depending upon whether block is odd or even. I hope my requirements are clear: background color varying with the odd or even number for the rows.
推荐答案
这可以通过向每隔一行添加一个不同的类来实现。
You're looking for alternating rows. This is accomplishable by adding a different class to every other row.
如何操作。
,而不添加类:
tr:nth-child(odd) { background-color:#eee; }
tr:nth-child(even) { background-color:#fff; }
这篇关于如何调整交替表行的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!