Re: On nth-child, etc..

fantasai wrote:
> I am arguing for
>   - the removal of :nth-last-child etc., with negative 
>     values taking its place
\
> 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)

Defining negative values to mean "count from the end"
yields some unexpected and odd results.
For example, :nth-child(7n-2..1) results in two negative
values when n=0, -1 and -2, causing the last two elements
to be selected, which is probably not the intent of the
author.

Given the general form An+B..C, this problem can be avoided 
by using A as a determinant:
  - if A > 0, then only positive results from the An+B..C
              expression will be processed; negative values
              are discarded
  - if A < 0, then only negative values are processed
  - if A = 0, then no restrictions are placed.
              Thus :nth-child(-5..5) selects the same 
              elements as :nth-child(1..5), :nth-child(-1..-5)

Received on Wednesday, 18 April 2001 22:41:36 UTC