CSS3/jQuery 选择器通过 :nt-child() 选择器设置 2 行组的样式
我有一个 ,数据按 2
分隔,
所以我想将行(每 2 行)设置为斑马条纹,但每套 2 件都应该设计风格。
我正在尝试这样的事情:
tr:nth-child(3n+1), tr:nth-child(4n+1){background:#f7f7f7;}
我更喜欢 CSS3 解决方案,但如果只有 jQuery 可以做到,那就没问题了。
请参阅演示(可通过jsFiddle编辑):
我尝试使用css技巧nth-child-tester,但我无法获取它。
问题是我如何设计每组(2)TR(行)的斑马样式
I have a <table>
that the data is separated per 2 <tr>
's
So i want to style the rows(each 2 rows) as zebra stripped, but each set of 2 should be styled.
I am trying something like:
tr:nth-child(3n+1), tr:nth-child(4n+1){background:#f7f7f7;}
I would prefer a CSS3 solution, but if only jQuery can do it, that will be fine.
Please see demo here (editable via jsFiddle):
I tried to play around with css-tricks nth-child-tester, but i couldn't get it.
The question is how do i zebra style each set of (2) TR's (rows)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里是一个分叉,其中每对行都有样式。
我必须编辑颜色才能看到任何东西。
您需要使用 (4n+1) 和 (4n+2)。
Here is a fork where every pair of rows is styled.
I had to edit the colour to see anything.
You need to use (4n+1) and (4n+2).
这对你有用吗?
这会将成对的行交替着色为红色和绿色。
Would this work for you?
This will color pairs of rows alternating as red and green.
其中任何一个都可以:
Either of these would work: