问题描述
我有这个片段的SASS代码:
只是连接字符串?
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内置函数时出现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!