jeudi 4 août 2016

Scss random image in rails app, not that random after all

In my app I want header images on a categories page to show up randomly, selecting from 5 jpg pictures.

In my categories.scss I have this code, but it only show the last picture 5.jpgno matter what.

Am I missing something?

How can I modify this to be like more random?

$imgKey: random(5);

$list: 1, 2, 3, 4, 5;
$nth: nth($list, $imgKey);

#necklace_header {

    background: asset-url( "assets/rand_headers/#{$nth}.jpg");
    width: 100%;
    background-repeat:no-repeat;
    background-position: top center;

    background-size: cover;  

    height: 360px;
    margin-bottom: 20px; 

}




Aucun commentaire:

Enregistrer un commentaire