Sass的最新版本(v3.3.0)添加了新
random功能。如果将其与图像列表(以及少量的变量插值)混合使用,则每次编译Sass时,CSS都会带有随机选择的背景图像。例:
$imgKey: random(5);$list: apple, banana, cherry, durian, eggplant;$nth: nth($list, $imgKey);body { background-image: "/images/#{$nth}.jpg";}如上所述,随机值仅在 编译Sass 时才会更改,而不一定在每次访问页面时更改。



