I want to apply some CSS on second active class. Only two element can have active class at a time.
I have tried the following CSS selectors:
.p .active:last-of-type
.p .active:nth-of-type(2)
But neither of them are working. Please tell me what I'm doing wrong.
Here is my code:
.p .active:nth-of-type(2){
background: red;
}
<div class="p">
<div class="a">The first paragraph.</div>
<div class="a active">The second paragraph.</div>
<div class="a active">The third paragraph.</div>
<div class="a">The fourth paragraph.</div>
</div>