I have this example:
<div class="container">
    <div class="item-1"></div>
    <div class="item-2"></div>
    <div class="item-2"></div>
    <div class="item-2"></div>
    <div class="item-3"></div>
    <div class="item-3"></div>
</div>
... and the item-# could be as high as 48. What I want to do is target each unique .item-# and give it a different color.
I tried playing around with this in SCSS:
@for $i from 1 through 48 {
    .item-#{$i} { 
       &:nth-child(1):nth-last-child(2),
       &:nth-child(2):nth-last-child(1) { 
            color: red; } 
       }
}
... but it didn't work. I found a similar solution here: Can CSS detect the number of children an element has?, but the difference is that I need all .item-# to be wrapped in a single container.
I'd like to avoid using JavaScript.
 
     
    