首页 > 解决方案 > 更改表格中某些行的颜色 - wordpress

问题描述

我有一个表,我想在其中使第 1、3、4 列填充这种颜色“#e1e1e1”。我该怎么做?

https://www.sebuys.com/shop/windows-10-customised-i7-i5-7th-gen-rgb-gaming-tower-16gb-8gb-ddr4-pc-computer/

桌子

标签: phphtmlcsswordpress

解决方案


查看 nth-child 选择器:http ://css-tricks.com/useful-nth-child-recipies

td:nth-child(1),
td:nth-child(3),
td:nth-child(4){
  background-color: #e1e1e1;
}
<table>
  <tbody>
    <tr>
      <td>Col 1</td>
      <td>Col 2</td>
      <td>Col 3</td>
      <td>Col 4</td>
    </tr>
    <tr>
      <td>Col 1</td>
      <td>Col 2</td>
      <td>Col 3</td>
      <td>Col 4</td>
    </tr>
    <tr>
      <td>Col 1</td>
      <td>Col 2</td>
      <td>Col 3</td>
      <td>Col 4</td>
    </tr>
    <tr>
      <td>Col 1</td>
      <td>Col 2</td>
      <td>Col 3</td>
      <td>Col 4</td>
    </tr>
  </tbody>
</table>


推荐阅读