Get another random number in SCSS loop for loop
I'm trying to generate a random number on each iteration of a for loop in SCSS, however, it just returns the same number on the DOM load for all elements oriented in the loop. I'm sure my syntax is correct, but clearly not!
Premises: I am building a brick wall and applying a different brick texture / image to each brick through the SCSS loop. I am trying to apply a random background image for 16 elements with a potential of 6 background images to choose from. My SASS is version 3.4.14.
** scss -v Sass 3.4.14 (Selective Steve) **
@for $i from 1 through 6 {
&.front:nth-child(#{$i}), &.back:nth-child(#{$i}) {
$brick-bg: '../image/brick' + random(6) + '.jpg';
background-image: url($brick-bg);
background-size: 100% 100%;
}
}
+3
TibblesScribbles
source
to share
No one has answered this question yet
See similar questions:
ten
or similar:
3324
1799
1758
1710
1597
771
724
662
615
376