M
M
mukzer2021-07-19 21:04:21
css
mukzer, 2021-07-19 21:04:21

What am I doing wrong with nth-child()?

What am I doing wrong with :nth-child()? I want to make such a gallery, but without additional classes...
I get such a gallery only if I add additional classes to each photo, and I'm trying to do it with nth-child(), so that without classes, but by element number, but when I add more elements, everything breaks for me....
codepen
60f5be913463f700303623.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RAX7, 2021-07-19
@mukzer

&:nth-child(6n + 1) {
    grid-column: 1 / 3;
}

&:nth-child(6n + 2) {
    grid-column: 3 / 4;
}

&:nth-child(6n + 3) {
    grid-column: 4 / 5;
}

&:nth-child(6n + 4) {
    grid-column: 1 / 2;
}

&:nth-child(6n + 5) {
    grid-column: 2 / 3;
}

&:nth-child(6n + 6) {
    grid-column: 3 / 5;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question