具有多个参数的LESS混合 [英] LESS mixins with multiple arguments
本文介绍了具有多个参数的LESS混合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个小混音设置:
.linear-gradient(@direction:top,@ color1:#fff ,@ color2:#000)
{
background-image:-webkit-linear-gradient(@direction,@ color1,@ color2);
}
然后,在 main.less
我正在尝试这样的:
一个{.linear-gradient(top,#999,#666 ); }
这很好,我想做这样的事情:
a {.linear-gradient(top,,#666); }
现在,第一种颜色应该默认为默认混合颜色。我如何做到这一点?这是可能的
解决方案
更少不是那么聪明。您可以是显式的:
.linear-gradient(top,#fff,#000);
或者使用变量作为默认值的传递。
@ colorVar1:#fff;
.linear-gradient(top,@ colorVar1,#000);
Less不知道如何处理一个空格, p>
I have this little mixin set up:
.linear-gradient(@direction:top, @color1:#fff, @color2:#000)
{
background-image: -webkit-linear-gradient(@direction, @color1, @color2);
}
Then, in my main.less
I'm trying something like this:
a { .linear-gradient(top, #999, #666); }
That works fine, by say I want to do something like this:
a { .linear-gradient(top, , #666); }
Now, the first color should default to its default mixin color. How do I do this? Is this even possible
解决方案
Less isn't quite that clever. You can either be explicit:
.linear-gradient(top, #fff, #000);
or use a variable as an abstraction to pass in the defaults.
@colorVar1: #fff;
.linear-gradient(top, @colorVar1, #000);
Less doesn't know how to handle an empty space, and will treat is as invalid.
这篇关于具有多个参数的LESS混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文