Within my code, I have a CSS variable called --num that holds a numerical value.
Under the same parent, I have N HTML elements as children. Element n and element n+1 are neighboring siblings. Essentially, all N elements are adjacent to each other.
Is there a way for me to only display element n from this collection of elements if n is less than the value stored in --num?
I've attempted referencing CSS variables in selectors like :nth-child( var(--num)), but it seems that can only be done within styles.
While one option could involve using JavaScript to retrieve --num and loop through the elements, adjusting their display property, I'm curious if there might be a more elegant solution. Are there any clever CSS tricks available that could achieve similar functionality without needing JavaScript?