我现在有这个长期统治如何将nth-child()规则合并为一个?
#content #wrapper table td:nth-child(3),
#content #wrapper table td:nth-child(4),
#content #wrapper table td:nth-child(5) {
width: 30px;
}
是有可能的第n个孩子结合起来,缩短东西像nth-child(3,4,5)
而不是3个独立的线路?
我现在有这个长期统治如何将nth-child()规则合并为一个?
#content #wrapper table td:nth-child(3),
#content #wrapper table td:nth-child(4),
#content #wrapper table td:nth-child(5) {
width: 30px;
}
是有可能的第n个孩子结合起来,缩短东西像nth-child(3,4,5)
而不是3个独立的线路?
这应该做的伎俩:
#content #wrapper table td:nth-child(n+3):nth-child(-n+5) {
width: 30px;
}
不是我知道我害怕。如果你为了使它更易于维护而寻找更少的代码,你可以尝试类似SASS的东西。
不是直接基于你的代码,但这应该给你一个想法。
ul li:nth-child(n+3):nth-child(-n+7){ }
您可以尝试
#content #wrapper table td:nth-child(n+3)
将所有选择,但第一2.
这作品,非常感谢你!你能解释最后一部分,我不知道它是如何工作的 – skyisred 2013-03-05 22:28:20
@skyisred你可能想玩这个http://lea.verou.me/demos/nth.html – Ana 2013-03-05 23:16:34