I want to set second child with class active special rules but I cannot target it. I have got 10 items and few of them have got active classes. I need to target second child with active class.
Is there any way to use nth-child
and combine two classes?
.container {
border: 2px solid red;
display: grid;
grid-auto-columns: 1fr;
grid-auto-flow: column;
column-gap: 3rem;
}
.item {
background-color: pink;
}
.item.active {
font-size: 2rem;
}
// Works when passed 5
.item.active:nth-child(2) {
background-color: yellow;
}
<div class="container">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item active">4</div>
<div class="item active">5</div>
<div class="item active">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
<div class="item">10</div>
</div>