I have a list of divs
that appear 4 in a row with a class and I would like to create a checkerboard background style, meaning:
- Apply a different background color for odd and even
divs
- Switch the odd-even to even-odd for each line
I've tried this
.boxwrapper:nth-child(2n-1), .boxwrapper:nth-child(2n) {
background:#ff0000;
}
.boxwrapper:nth-child(4n-2), .boxwrapper:nth-child(4n-3) {
background:#0000ff;
}
and it works fine for odd-even divs but cant get it to switch every 4 items. I'm headaching over the 4n-1, 4n+1 stuff, if I could get that right voila!
The result should look like this:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…