Css 如何覆盖tr:n个子项(2n)?
站点范围的样式表具有以下形式的指令Css 如何覆盖tr:n个子项(2n)?,css,Css,站点范围的样式表具有以下形式的指令 #outerdiv tr:nth-child(2n) { background-color: #cccccc; } 我想为div#innerdiv中包含的表覆盖它,而div中又包含了outerdiv 我发现唯一有效的方法是: #innerdiv tr:nth-child(2n) { background-color: #ffffff; } 这在我看来过于具体,可能非常脆弱 是否有其他方法可以撤销站点范围的指令?或者,是否有方法为#inner
#outerdiv tr:nth-child(2n) {
background-color: #cccccc;
}
我想为div#innerdiv
中包含的表覆盖它,而div中又包含了outerdiv
我发现唯一有效的方法是:
#innerdiv tr:nth-child(2n) {
background-color: #ffffff;
}
这在我看来过于具体,可能非常脆弱
是否有其他方法可以撤销站点范围的指令?或者,是否有方法为#innerdiv
中的所有表行指定背景色
FWIW,以下情况不起作用:
#innerdiv tr {
background-color: #ffffff; !important;
}
试试这个
#innerdiv tr {
background-color: #ffffff !important;
}
试试这个
#innerdiv tr {
background-color: #ffffff !important;
}
根据表的嵌套方式,如果第一个表是
#outerdiv
的直接子表,则可以使用以下代码:
table tr {
background-color: #fff
}
#outerdiv > table tr:nth-child(2n) {
background-color: #cccc;
}
根据表的嵌套方式,如果第一个表是
#outerdiv
的直接子表,则可以使用以下代码:
table tr {
background-color: #fff
}
#outerdiv > table tr:nth-child(2n) {
background-color: #cccc;
}
背景色:#ffffff!重要的代码>非背景色:#ffffff!重要的代码>尝试此选择器:#innerdiv>tr{背景色:#ffffff;}
它是背景色:#ffffff!重要的代码>非背景色:#ffffff!重要的代码>尝试此选择器:#innerdiv>tr{背景色:#ffffff;}