ODD/EVEN表中只有两列

Ser*_*tas -3 html css html-table class

我想创建这样的效果来改变背景ODD/EVEN到每个<TR>只有字段class="important"..下面它是一个表的例子...它不是静态的...它是由PHP创建的,来自Mysql的数据...

<tr class="change">
   <td>1111</td>
   <td>2222</td>
   <td>3333</td>
   <td>4444</td>
   <td class="important">5555</td>
   <td class="important">6666</td>
<tr>
<tr class="change">
   <td>1111</td>
   <td>2222</td>
   <td>3333</td>
   <td>4444</td>
   <td class="important">5555</td>
   <td class="important">6666</td>
<tr>
Run Code Online (Sandbox Code Playgroud)

因此,我希望每个<TR>ODD或EVEN仅根据CLASS IMPORTANT对表中的几个单元格进行影响

Com*_*eek 5

这会解决您的问题吗?

tr.change:nth-child(even) td.important {
  background: #CCC;
}

tr.change:nth-child(odd) td.important {
  background: #FFF;
}
Run Code Online (Sandbox Code Playgroud)