使用标准列表,我试图选择最后两个列表项。我有各种排列的 An+B
,但似乎没有选择最后2:
li:nth-child(n+2) {} /* selects from the second onwards */
li:nth-child(n-2) {} /* selects everything */
li:nth-child(-n+2) {} /* selects first two only */
li:nth-child(-n-2) {} /* selects nothing */
我知道一个新的 CSS3选择器,如 :nth-last-child()
,但我更喜欢的东西,工作在一些更多的浏览器,如果可能的话(不关心 IE 特别)。