Complex zebra pattern

I am trying to color coded list, essentially a LONG zebra stripe pattern. Essentially the seven items are different colors 1-7, then the color repeat. I normally love math, but I am just having a little trouble figuring out the formula for the n-th child pattern.

currently I have :

        .bxslider li .contenttitle { background: #ed1c22 /*innove red*/; color: #fff;}
        .bxslider li:nth-child(2n) .contenttitle{background: #009200 ; color: #fff}
        .bxslider li:nth-child(3n) .contenttitle{background: #ff6700; color:#fff; }
        .bxslider li:nth-child(4n) .contenttitle{background: #9e00c1 ; color: #fff}
        .bxslider li:nth-child(5n) .contenttitle{background: #ffd905; color:#222 }
        .bxslider li:nth-child(6n) .contenttitle{background: #e81396;  color: #fff}
        .bxslider li:nth-child(7n) .contenttitle{background: #5099e6; color: #fff }

but only producing a a “random” color pattern after the first 7

li:nth-child(n+x) doesnt seem to work either

any suggestions would be greatly apporeciated!

Alright so look at this example.

Do you understand the nth child logic in this below example? It’s saying "select every 7th element STARTING at 1…2…3 etc etc.

 li:nth-child(7n+1){background: green; color:#fff; }
         li:nth-child(7n+2) {background: blue ; color: #fff}
       li:nth-child(7n+3) {background: yellow; color:#222 }
        li:nth-child(7n+4){background:purple;  color: #fff}
         li:nth-child(7n+5){background: black; color: #fff }
         li:nth-child(7n+6){background: white; color: #000 }
         li:nth-child(7n+7){background: red ; color: #fff}

I changed the values of your properties for my testing purposes.

1 Like

Made a jsfiddle for you to see more easily.

::face palm:: YES… that was an obvious brain f@rt… i remembered the logic right after I posted. (for whatever reason , I didnt visualize as N starting from ZERO, and thought I would have had to have coded the first seven separately) I really need a vacation. Thanks Ryan.

It happens :slight_smile: you just needed a second set of eyes. You’re welcome.

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