I want to have a series of elements, and I want to have incremental background colors, but I also want to not hard-code it in order to allow for future expansion.
<div class="container">
<div>one</div>
<div>two</div>
<div>three</div>
</div>
I could do something like this:
.container div:nth-child(0) {
background-color: #0000ff;
}
.container div:nth-child(1) {
background-color: #000066;
}
.container div:nth-child(2) {
background-color: #000000;
}
I would rather do that with a single rule, which would allow more succinct code and also allow for more extensibility (for, say, 6 elements). Is this even possible? I am aware that something like this is pretty straightforward with JQuery, but I would rather just use CSS if possible.