Using a standard list, I'm trying to select the last 2 list items. I've various permutations of An+B
but nothing seems to select the last 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 */
I'm aware of a new CSS3 selectors like :nth-last-child()
but I'd prefer something that works in a few more browsers if possible (don't care about IE particularly).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…