【发布时间】:2018-08-21 21:23:35
【问题描述】:
我已经阅读了多篇关于此的文章,但我无法让它在我有一个颜色列表并且我希望刷新以将其中一种颜色应用为背景图像的情况下工作。
$red: #fc5545;
$pink: #FCCCD1;
$green: #005E61;
$greenLight: #42BA80;
$yellow: #ffcf6f;
$orange: #F57859;
$orangeLight: #FABD91;
$greyLight: #ebebeb;
$greyDark: #2e2e2e;
$blue: #29A8BF;
$blueLight: #B8E3EB;
$blueDark: #142447;
$colors: $pink, $green, $greenLight, $yellow, $orange, $orangeLight, $blue, $blueLight, $blueDark;
$colorsText: $blueDark, $orangeLight, $blueLight, $red, $blueLight, $red, $blueLight, $blue, $pink;
$key: random( length($colors) );
$nth: nth( $colors, $key );
$nthText: nth( $colorsText, $key );
$random: $nth !default;
$randomText: $nthText !default;
.boxTitle {
background-color: $random;
color: $randomText !important;
}
每次刷新,颜色都一样。
【问题讨论】:
-
缓存问题?
-
sass 有它的位置,但你很可能需要 JavaScript 来应用在页面刷新时加载的随机值。