[英]CSS select element with class, only if it is NOT first child of parent
I have a div.container that has lots of p elements inside it. 我有一个div.container ,其中有很多p元素。 Few of them has class p.special .
他们中很少有人有p.special课 。 I need to select p.special elements, but ONLY if they are NOT at the very top of the parent element (not first child element of parent .container ).
我需要选择p.special元素,但是仅当它们不在父元素(不是parent .container的第一个子元素)的最顶部时才选择 。
PS I know this can be done easily with jQuery, but I'd prefere plain CSS solution for this. PS我知道这可以很容易地用jQuery完成,但是我更喜欢普通的CSS解决方案。
Here I made explaining sample picture to make myself clear: 在这里,我解释了示例图片以使自己清楚:
使用:not
和:first-child
选择器应该做到这一点。
.special:not(:first-child) {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.