8000 [css-values] Function to retrieve index of element among siblings, or counter on element as integer · Issue #1869 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-values] Function to retrieve index of element among siblings, or counter on element as integer #1869

@Nokel81

Description

@Nokel81

Currently you can write the following with the :nth-child or similar style selectors

.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:

.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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0