CSS is even odd for every other odd div in the class

I have divs in a horizontal line, all in one class, for example:

1 2 3 4 5 6 7 8 9 10

I want to use css for every other odd line, so 1,5,9, etc.

I tried

.myClass:nth-child(n+4) and .myClass:nth-child(odd),.myClass:nth-child(odd){ 

but can not understand: (

+6
source share
2 answers

:nth-child(4n) gives us 0, 4, 8, etc.

Since you want 1, 5, 9, you should try :nth-child(4n + 1)

+10
source

What you want to do is apply CSS to every fourth line, so you want:

 .myClass:nth-child(4n+1) 
+3
source

Source: https://habr.com/ru/post/955436/


All Articles