- From: Bramus! via GitHub <sysbot+gh@w3.org>
- Date: Thu, 17 Nov 2022 14:28:12 +0000
- To: public-css-archive@w3.org
> Allow styling of the parent based on the number of children.
This is possible nowadays, thanks to `:has()`:
```css
/* Less than 3 children */
ul:has(> :nth-child(-n+2):last-child) {
border: 1px solid red;
}
/* Exactly 5 children */
ul:has(> :nth-child(5):last-child) {
border: 1px solid blue;
}
/* More than 7 children */
ul:has(> :nth-child(7)) {
border: 1px solid green;
}
```
Try it out in your browser if it has `:has()` support: https://codepen.io/bramus/pen/bGKoZNq?editors=0110
I guess this issue may be closed?
--
GitHub Notification of comment by bramus
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1547#issuecomment-1318720615 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 17 November 2022 14:28:14 UTC