Created
April 1, 2019 14:56
-
-
Save maxxcrawford/92356e1517e2be92074cbfa9e4a0500d to your computer and use it in GitHub Desktop.
Color selector based on column count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const colors = ['yellow', 'pink', 'blue', 'orange', 'teal'] | |
function colorRows (colCount) { | |
for (let i = 0; i < items.length; i++) { | |
const item = items[i] | |
const row = Math.floor(i / colCount) | |
const col = i % colCount; | |
const index = (row + col) % colors.length | |
item.style.background = colors[index] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment