我想在某些容器上设置伪元素边框,但排除第三个元素。我想我可以将伪选择器与:not
结合使用,例如:div:before:not(nth-child(3))
,但它似乎不起作用。创建伪元素,但排除特定元素(不包含:nth-child)
那么:not
选择器是否与伪选择器不兼容?在那种情况下,我如何才能使它具有伪元素并排除某些特定元素?
(顺便说一句,与伪元素边框的想法是控制边界,让他们留在上面,无论是否有顶部(还没有看到任何重叠,如果它工作虽然)
这里小提琴:(有因为没有没有明显的边界:(第n个孩子(3))选择)
下面是从小提琴代码:
HTML:
<div class="ctr">
<div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
</div>
</div>
CSS:
.ctr > div div{
float:left;
width:100px;
height:100px;
background:black;
/*border:green 3px solid; */
}
.ctr > div:after{
content:"";
display:block;
clear:both;
}
.ctr > div div{
position:relative;
}
/* only if I remove ":not(:nth-child(3))" , the pseudo selector will appear: */
.ctr > div div:before:not(:nth-child(3)){
content: "";
display: block;
z-index: 2;
position: absolute;
left:0;
right:0;
bottom:0;
top:0;
height: 100%;
width: 100%;
border-right: 0.35em red solid;
border-bottom: 0.35em red solid;
}
是它的工作伪元素(我想我我以前试过,但一定是犯了一些错误,导致它不能正常工作)。感谢提醒有关双冒号。 – Galivan