上海社会科学院挑颜色随机从数组 [英] SASS pick random color from an array
问题描述
是否有可能,使用SASS,来定义颜色数组,然后随机选择一个并把它应用到一个元素?
Is it possible, using SASS, to define an array of colors and then pick one at random and apply it to an element?
提前非常感谢。
推荐答案
编辑:这是现在直接支持萨斯
This is now supported directly in Sass
虽然它不能直接在上海社会科学院的支持下,你可以使用 HTTP://$c$cpen.io 来访问他们的萨斯编辑的随机()函数。
Although its not supported directly in sass, you can use http://codepen.io to access the random() function in their Sass editor.
HTTP://blog.$c $ cpen.io / 2013/8月26日/随机函数在上海社会科学院/
https://gist.github.com/chriseppstein/1561650
但正如上面在评论中提到的,只有当你编译CSS发生,但CSS本身仍然会只有一个静态值,你的名单
But as mentioned in the comments above, it only happens when you compile the CSS, but the CSS itself is still going to have only a static value out of your list
这篇关于上海社会科学院挑颜色随机从数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!