Nth-child on div

Is there a way to apply the nth-child pseudo-clas on a DIV?

I am wrapping items in my checkout in DIV’s and would like to alternate the background shading for readability.

<div class="checkoutItem">
     <!-- Item goes here -->
</div>

Not sure if nth-child only applies to elements like LI’s. :wonky:

It looks like this is valid…

.checkoutItem:nth-child(even){
     background-color: #EEE;
}

<div class="checkoutItem">
     <!-- Item goes here -->
</div>

Have you tried it? Does it work?

1 Like

I already answered your questions in post #2.

That doesn’t say that you tried it nor whether it works.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.