Tech
Get item index and item count in CSS
sibling-index() and sibling-count()
For years, CSS had no way of knowing which position an element had among its siblings, or how many siblings there were. Now it does. With sibling-index() and sibling-count() you can finally get the item index and item count directly in CSS.
sibling-index() returns the element's position among its siblings, starting at 1 .
sibling-count() returns the total number of siblings, including the element itself.
How we used to do it...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to