W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2017

[csswg-drafts] [css-selectors] nth-child produces a local variable

From: Sebastian Malton via GitHub <sysbot+gh@w3.org>
Date: Fri, 13 Oct 2017 22:28:20 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-265434976-1507933685-sysbot+gh@w3.org>
Nokel81 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-selectors] nth-child produces a local variable ==
Currently you can write the following with the `:nth-child` or similar style selectors
```css
.foobar>*:nth-child(2n) {
    background-color: lime;
}
```

Which means that every second child has a background colour of lime. However you cannot do something like the following:

```css
.foobar {
    display: grid;
    grid-template-columns: 100px 1fr;
}
.foobar>*:nth-child(2n) {
    grid-column: 1/2;
    grid-row: n;
}
.foobar>*:nth-child*(2n+1) {
    grid-column: 2/3;
    grid-row: n;
}
```

I think that this would be very useful and would make working with grids quite a bit more easy

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1869 using your GitHub account
Received on Friday, 13 October 2017 22:28:08 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:19 UTC