I want to set a pseudo element border on some containers, but exclude the third one. I thought I could combine the pseudo selector with :not
, like: div:before:not(nth-child(3))
, but it doesn't seem to work.
So is the :not
selector incompatible with pseudo selectors? In that case, how can I make it work putting pseudo elements and exclude some specific elements?
(By the way, the idea with pseudo element borders is to control the borders so that they stay on top regardless if there are any overlays on top (haven't seen if it works though)
Here is a fiddle: (there are no visible borders because of the not:(nth-child(3)) selector)
Here is the code from the fiddle:
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;
}