I have a dynamic page where the user can add as many div inside other div as he wants. Each div has a background color and I want the background color to repeat itself every 3 divs.
Currently, I'm writing the css rules like this
div {
padding-top: 20px;
margin-left: 10px;
}
div {
background-color: blue;
}
div>div {
background-color: red;
}
div>div>div {
background-color: green;
}
div>div>div>div {
background-color: blue;
}
div>div>div>div>div {
background-color: red;
}
div>div>div>div>div>div {
background-color: green;
}
div>div>div>div>div>div>div {
background-color: blue;
}
/* and it continues... */
<div>
<div>
<div>
<div>
<div>
<div>
<div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Is there another way to do it with CSS?