in case you using SASS: you can use this snippet and change accordingly
$colors: red, orange, yellow, green, blue, purple;
$repeat: 20 // How often you want the pattern to repeat.
// Warning: a higher number outputs more CSS.
@for $i from 1 through $repeat {
.gallery img:nth-child(#{length($colors)}n+#{$i}) {
border-color: lighten(nth($colors, random(length($colors))), 20%);
}
}
.gallery img {
list-style: none;
padding: 1em;
}
if you can’t work with SASS than you must use a javascript / jquery solution to achieve that. I posted a snippet that generates random color values. now you only need to find a logic to get the colors to the appropriate items.
var color = "#" + Math.floor(Math.random() * 0xFFFFFF).toString(16);
If you need further help, post some more code