How to select the first and the fourth element?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
7 views
I have elements
5ae58b66a1347562240089.jpeg

So, you need to select the background in a checkerboard pattern. For this to be done in the background styles for the first and fourth. Only elements not four, and more, that is, the formula should work for each of the first and fourth.
by | 7 views

3 Answers

0 like 0 dislike
&:nth-child(4n),
&:nth-child(4n + 1) {
background: #f3f3f3;
}
by
0 like 0 dislike
Probably more logical than the formula on the first and fourth, and in turn?

:nth-child(even) {background: #CCC} :nth-child(odd) {background: #FFF}
by
0 like 0 dislike
.element:first-child//first element
element:nth-child(4n)//every fourth
by

Related questions

0 like 0 dislike
4 answers
asked Sep 10, 2019 by strelkovandreyvalerievich
0 like 0 dislike
4 answers
asked Aug 4, 2019 by strelkovandreyvalerievich
0 like 0 dislike
4 answers
asked Jul 1, 2019 by strelkovandreyvalerievich
0 like 0 dislike
4 answers
asked Jul 9, 2019 by strelkovandreyvalerievich
0 like 0 dislike
2 answers
asked May 3, 2019 by verycooldev
110,608 questions
257,186 answers
0 comments
35,573 users