如何在SASS的最小和最大参数内生成随机数? [英] How to generate a random number within a min and max parameters in SASS?
本文介绍了如何在SASS的最小和最大参数内生成随机数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在SASS的最小和最大参数内生成随机数?例如5到15之间的一个随机数.
How to generate a random number within a min and max parameters in SASS? For example a random number from 5 to 15.
.foo
font-size: random(15)#{px}
如果这不可能,那么类似的公式是什么?
If that is not possible, what would be a similar formula?
谢谢!
推荐答案
SASS中没有设置最小值.
There is no minimum value to set in SASS.
但是您可以按照以下方法对5到15之间的随机数进行调整.
But you can tweak it as follows for a random number from 5 to 15.
.foo
font-size: (random(11) + 4)+px
将4加到11,因为random()
函数的最小值为1
added 4 to 11, because random()
function has minimum value of 1
这篇关于如何在SASS的最小和最大参数内生成随机数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文