Re: [selectors] Proposal: :n-children() selector

On Tue, Feb 3, 2015 at 8:46 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> With that, you could do something like:
>
> @custom-selector $rest:--n-siblings($n)
> :nth-child(1):nth-last-child($n) /self-and-siblings/ $rest;
>
> So that writing `.foo:--n-siblings(3)` would become
> `:nth-child(1):nth-last-child(3) /self-and-siblings/ .foo` after
> expansion.

Well, I guess we don't really need new combinators; it just makes it a
bit more convenient.  Without that, you could write it as:

@custom-selector $rest:--n-siblings($n)
:nth-child(1):nth-last-child($n)$rest,
:nth-child(1):nth-last-child($n) ~ $rest;

And with some ability to select parents, you could write
:--n-children() in a similar way.

~TJ

Received on Wednesday, 4 February 2015 04:52:48 UTC