Re: On nth-child, etc..

Jonas Sicking wrote:
> 
> I totally agree with you, I first saw using negative indexnumbers in perl
> and have loved the syntax ever since. However it dosn't really fit nicly
> with the an+b synax, though it surly could be done. The following syntax
> could be used:
> :nth-child(-1..10)  /* ten last children */
> :nth-child(-3n-1)  /* same as 3n+1 (1,4,7...) but count from behind */
> :nth-child(-3n+1)  /* same as 3n-1 (2,5,8...) but count from behind */

IMO, the last ten children should be expressed as
  :nth-child(-1..-10)
This is more consistent and more logical. The range
should trace along the numberline, starting at b and
ending at c.

It also allows you to use :nth-child(7n-2..1) to mean
take every seventh, as well as two before and one after it -
  :nth-child(7n-2), :nth-child(7n-1), :nth-child(7n), :nth-child(7n+1)

> 
> so counting would be done from behind if the *first* number is negative.
> Unfortunatly the last two rules aren't very intuitive (but IMHO more logical
> then the current meaning of -3n+1).
> 
> You could also allow signs on the c constant which would also allow
> selectors like
> 
> :nth-child(5..-5) /* fifth child to fifth last child */
> 
> which the currently has to be done using either :not() or several rules
> "undoing" each other. 

Only two - :nth-child(n+5):nth-child(-n-5)

> However, what would a rule like :nth-child(-3n-1..10) mean?

As I see it, :nth-child(-3n-1), :nth-child(-3n), :nth-child(-3n+1..10)

~fantasai

Received on Saturday, 10 March 2001 12:38:58 UTC