Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save allilevine/d97664b2ce981894f755 to your computer and use it in GitHub Desktop.
Save allilevine/d97664b2ce981894f755 to your computer and use it in GitHub Desktop.
// I wanted to use this method (http://codepen.io/jcasabona/pen/fKgCA) of displaying random background images with Sass, but I didn't want to type out each image file name, so instead I used a loop:
$random_images_path: "../../../uploads/";
$imagesarray: ('');
@for $i from 1 through 40 {
$value: $random_images_path + "/sitename" + $i + ".jpg";
$imagesarray: append($imagesarray, $value);
}
$img: nth($imagesarray, random(length($imagesarray) -1));
#content {
background: url($img) no-repeat center center;
background-size: cover;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment