调用SASS内置函数时出现的问题 [英] Problems calling a SASS built-in function
问题描述
我有这个片段的SASS代码:
@ font-face {
$ rndnum:random );
font-family:myfont;
src:url('fonts / myfont#{$ rndnum} .svg')
font-weight:bold;
font-style:normal;
}
我需要在字体名称后面加一个随机数字,我知道看来愚蠢的操作,但我需要它。但是问题是我得到以下结果:
@ font-face {
font-family:myfont;
src:url('fonts / myfontrandom(1000).svg')/ *< == HERE * /
font-weight:bold;
font-style:normal;
}
此函数不会因为某种原因而被调用...
更多...
我尝试调用另一个函数,例如 percentage
:
@ font-face {
$ rndnum:percentage 0.2);
...
在这种情况下工作...看起来不像 只是连接字符串?
src:url('fonts / myfont'+ $ rndnum +'。svg');
你有代码为 $ rndnum
被设置为因为这也可能是一个问题以及如何设置该变量。
编辑1:
你只需要 src
行后面的分号?
您使用什么版本的sass?
我尝试这里,它似乎工作完美在Sass版本3.3.3,但不是在版本3.2.15(在该网站提供的两个版本)。
I have this fragment of SASS code:
@font-face {
$rndnum: random(1000);
font-family: myfont;
src:url('fonts/myfont#{$rndnum}.svg')
font-weight: bold;
font-style: normal;
}
I need to put a random number after the name of the font, I know it seems stupid operation, but I need it. However the problem is that I get the following result:
@font-face {
font-family: myfont;
src:url('fonts/myfontrandom(1000).svg') /* <== HERE */
font-weight: bold;
font-style: normal;
}
The function does not get called for some reason... Where am I doing wrong?
Something more...
I tried calling another function like percentage
:
@font-face {
$rndnum: percentage(0.2);
...
And it worked in that case... looks like it is not recognizing random
as a valid function...
Have you tried just concatenating the string?
src:url('fonts/myfont'+$rndnum+'.svg');
And do you have the code for what $rndnum
is being set as since this could also be a problem with how that variable is set.
Edit 1:
Your code works for me. Do you just need the semi-colon after the src
line?
What version of sass are you using?
I tried it here and it seemed to work perfectly fine on Sass version 3.3.3 but not on version 3.2.15 (the two versions offered on that site).
这篇关于调用SASS内置函数时出现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!