css - looking for expression for nth-child style -


i want set styles child elements in groups of 4. expression need use in nth-child style? below changes styles every fourth element. want have first 4 black/white, second 4 white/black, etc.

ul li:nth-child(4n) {   background-color: black;   color: white; } ul li:nth-child(4n+1) {   background-color: white;   color: black; } 

it's possible there's better way, work:

ul li:nth-child(8n+1), ul li:nth-child(8n+2), ul li:nth-child(8n+3), ul li:nth-child(8n+4){     background-color: black;     color: white; } 

http://jsfiddle.net/uxgjd/


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -