I am trying to generate a random number upon each iteration of a for loop in SCSS, however it simply returns the same number on DOM load for all elements targeted within the loop. Im pretty sure my syntax is correct, but clearly not!
Premise: I am building a brick wall and applying a different brick texture/image to each brick via the SCSS loop.
@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%;
}
}
Aucun commentaire:
Enregistrer un commentaire