2013-03-05 23 views
6

我现在有这个长期统治如何将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个独立的线路?

回答

6

这应该做的伎俩:

#content #wrapper table td:nth-child(n+3):nth-child(-n+5) { 
    width: 30px; 
} 
+0

这作品,非常感谢你!你能解释最后一部分,我不知道它是如何工作的 – skyisred 2013-03-05 22:28:20

+0

@skyisred你可能想玩这个http://lea.verou.me/demos/nth.html – Ana 2013-03-05 23:16:34

-3

不是我知道我害怕。如果你为了使它更易于维护而寻找更少的代码,你可以尝试类似SASS的东西。

1

不是直接基于你的代码,但这应该给你一个想法。

ul li:nth-child(n+3):nth-child(-n+7){ }