W3C home > Mailing lists > Public > www-style@w3.org > February 2015

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 3 Feb 2015 20:52:00 -0800
Message-ID: <CAAWBYDAJtpOzcsaOH8kQmf-15t+fkoFQAftHBrX19Ba64fp1OQ@mail.gmail.com>
To: Matt Mastracci <matthew@mastracci.com>
Cc: Lea Verou <lea@verou.me>, www-style list <www-style@w3.org>
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;

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

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

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:48 UTC