相关疑难解决方法(0)

是否可以选择带有nth-child的最后n个项目?

使用标准列表,我正在尝试选择最后2个列表项.我有各种各样的排列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 */
Run Code Online (Sandbox Code Playgroud)

我知道有一个新的CSS3选择器,:nth-last-child()但我更喜欢在可能的情况下在更多浏览器中工作的东西(尤其不关心IE).

css css-selectors css3

115
推荐指数
3
解决办法
8万
查看次数

标签 统计

css ×1

css-selectors ×1

css3 ×1