特定表的CSS样式

时间:2017-06-02 10:00:26

标签: css wordpress

我被要求删除此页面中的灰色区域http://ccl.vincentandbell.com/partners/

我尝试为表格提供ID <div id="customtable">,并在我的style.css文件中添加了以下内容:

#customtable { 
    background-color: #fffff;
}

但是,这并没有改变灰色区域的颜色。

这是一个灰色区域的HTML:

<tr>
    <td width="105"></td>
    <td width="498"><strong>&nbsp;</strong><p></p>
        <h3>Cumbria Methodist District</h3>
        <p>
            <a href="http://www.cumbriamethodistdistrict.org.uk/welcome.htm">http://www.cumbriamethodistdistrict.org.uk/welcome.htm</a>
        </p>
    </td>
</tr>

CSS应用于它:

table tbody tr:nth-child(even) {
    background-color: #f2f2f2;
}

3 个答案:

答案 0 :(得分:0)

这里似乎有一个班级:

table tbody tr:nth-child(even)

你需要覆盖这个类:

table tbody tr:nth-child(even) {
    background-color: transparent!important;
}

答案 1 :(得分:0)

更改此

  table tbody tr:nth-child(even) {
      background-color: #f2f2f2;
  }

 table tbody tr:nth-child(even) {
      background-color: transparent;
  }

答案 2 :(得分:0)

1。)注意:您使用#fffff作为颜色值,这是一个无效的颜色值 - 使用eiter #fff#ffffff(6次f)< / p>

2。)理论上,它应该与这个CSS一起使用,正如@Daniel Fois写的那样,因为它对应于/覆盖原始的CSS规则:

table tbody tr:nth-child(2n) {
    background-color: #ffffff;
}

3。)如果它应该被限制在该特定页面(而不是整个网站),您可以在组合的CSS选择器中使用页面ID类page-id-16(在body标签中),以及如有必要,请添加!important

.page-id-16 table tr {
    background-color: #ffffff !important;
}