Skip to content

Instantly share code, notes, and snippets.

@maxxcrawford
Created April 1, 2019 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxxcrawford/92356e1517e2be92074cbfa9e4a0500d to your computer and use it in GitHub Desktop.
Save maxxcrawford/92356e1517e2be92074cbfa9e4a0500d to your computer and use it in GitHub Desktop.
Color selector based on column count
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