使用:nth-child和:nth-last-child同时 [英] Using :nth-child and :nth-last-child simultaneously
本文介绍了使用:nth-child和:nth-last-child同时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法使:nth-child
和:nth-last-child
运行良好(突出显示前3个元素):
Works well (highlights first 3 elements):
#a li:nth-child(-n+3) {
background: #fbfcc8;
}
效果很好(突出显示最后3个元素):
Works well (highlights last 3 elements):
#b li:nth-last-child(-n+3) {
background: #fbfcc8;
}
无效(突出显示前3个元素和最后一个元素):
Doesn't work (highlights first 3 elements and last one):
#c li:nth-child(-n+3), #c li:nth-last-child(-n+3) {
background: #fbfcc8;
}
更新:
实际上,我有更复杂的HTML,所以似乎只是一个错误。
In real I have more complicated HTML, so seems like it's just a bug.
推荐答案
这只是Google Chrome的一个错误Mac为31.0.1650.57。 Firefox,Safari和最新的Google Chrome浏览器运行良好。
It's just a bug in Google Chrome 31.0.1650.57 for Mac. Firefox, Safari and latest Google Chrome works well.
这篇关于使用:nth-child和:nth-last-child同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文