如何在CSS伪类选择器中排除最后一个孩子 [英] How to exclude last child in css pseudo class selector
本文介绍了如何在CSS伪类选择器中排除最后一个孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对从4到n-1的子div应用特殊的样式.我能够从4到n进行处理,但不能排除最后一个div
I want to apply a particular style for child div from 4 to n-1 .i was able to do from 4 to n , but could not exclude the last div
这是jsfiddle http://jsfiddle.net/8WLXX/
here is the jsfiddle http://jsfiddle.net/8WLXX/
.container div:nth-child(n+4) { background: red; }
我只想要排除最后一个div.
All I want is exclude last div also.
推荐答案
只需将:not(:last-child)
添加到选择器:
.container div:nth-child(n+4):not(:last-child)
这篇关于如何在CSS伪类选择器中排除最后一个孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文