Re: [csswg-drafts] Quantity Queries Proposal

If [`:has()`](https://drafts.csswg.org/selectors-4/#relational) were easier to implement, I think you could use
```css
.some-thing:has(> nth-child(4)) > li > a { /* 4 or more elements */ }
.some-thing:not(:has(> nth-child(4))) > li > a { /* 3 or less elements */ }
```

I don't think there is a strong need for `:of-child`. I think the real annoyance here is that the combinator `~`  is not inclusive. Say `~=` was a combinator like `~` but inclusive, then you could use

```css
.some-thing > :nth-last-child(n+4) ~= * > a { /* 4 or more elements */ }
.some-thing > :first-child:nth-last-child(-n+3) ~= * > a { /* 3 or less elements */ }
```

It would also be helpful for other kinds of problems. For example, say you want to split the elements into groups of three elements, allowing the last group to have one or two elements, and then select the elements in the last group.

Currently I think the best way to do this is
```css
.some-thing > :nth-last-child(-n+3):nth-child(3n+1) > a,
.some-thing > :nth-last-child(-n+3):nth-child(3n+1) ~ * > a
```

But with `~=`, it would be simpler:
```css
.some-thing > :nth-last-child(-n+3):nth-child(3n+1) ~= * > a
```


-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1176#issuecomment-292290484 using your GitHub account

Received on Thursday, 6 April 2017 19:38:28 UTC