【问题标题】:Changing the color of certain rows in a table - wordpress更改表格中某些行的颜色 - wordpress
【发布时间】:2019-08-24 06:28:53
【问题描述】:

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

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

【问题讨论】:

标签: php html css wordpress


【解决方案1】:

查看第 n 个子选择器: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>

【讨论】:

  • 您好,先生,实际上这适用于列表但不适用于表格 (td)。你能不能提供一些sebuys.com/shop/…
  • @codeisfun1234 这绝对适用。我已经为您添加了一个示例。
猜你喜欢
  • 1970-01-01
  • 2014-07-06
  • 2012-05-01
  • 2017-11-04
  • 2016-03-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-17
相关资源
最近更新 更多