Html 如何将n-child()规则合并为一个规则?
我现在有一条很长的规则Html 如何将n-child()规则合并为一个规则?,html,css,Html,Css,我现在有一条很长的规则 #content #wrapper table td:nth-child(3), #content #wrapper table td:nth-child(4), #content #wrapper table td:nth-child(5) { width: 30px; } 有没有可能将第n个孩子组合成更短的东西,比如第n个孩子(3,4,5),而不是3个单独的行?恐怕我不知道。如果您希望减少代码以使其更易于维护,您可以尝试类似SASS的方法。不直接基于您
#content #wrapper table td:nth-child(3),
#content #wrapper table td:nth-child(4),
#content #wrapper table td:nth-child(5) {
width: 30px;
}
有没有可能将第n个孩子组合成更短的东西,比如第n个孩子(3,4,5),而不是3个单独的行?恐怕我不知道。如果您希望减少代码以使其更易于维护,您可以尝试类似SASS的方法。不直接基于您的代码,但这应该会给您一个想法
ul li:nth-child(n+3):nth-child(-n+7){ }
你可以试试
#content #wrapper table td:nth-child(n+3)
将选择除前2个以外的所有
FROM:这应该可以做到:
#content #wrapper table td:nth-child(n+3):nth-child(-n+5) {
width: 30px;
}
这很有效,非常感谢!你能解释一下最后一部分吗?我不知道怎么解释works@skyisred你可能想玩一下这个