具有多个变量的 LESS mixin
我试图在 LESS 中制作一个包含多个变量的 mixin,但由于某种原因它不起作用。我有这个 LESS:
.rgbabg(@r: 0, @g: 0, @b: 0, @a: .5) {
@val: rgba(@r, @g, @b, @a);
background: @val;
}
我这样称呼它:
.rgbabg(255, 0, 0, .5);
但我根本没有得到任何关于我的元素的背景。我的语法没问题吗?
I'm trying to make a mixin with multiple variables in LESS, but for some reason it's not working. I have this LESS:
.rgbabg(@r: 0, @g: 0, @b: 0, @a: .5) {
@val: rgba(@r, @g, @b, @a);
background: @val;
}
I call it like this:
.rgbabg(255, 0, 0, .5);
But I don't get any background on my element at all. Is my syntax ok?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的 mixin 的语法很好,并且编译得很好。我在我的 LESS 转换器 中尝试了一下,一切都很好。我将规则应用于
a
标签选择器的页面:它输出:
为我的链接着色,就像听起来应该的那样。
您使用什么版本的 LESS 进行编译 - 编译器的平台和版本是什么?我不会推荐 Ruby 编译器,因为我认为它已经不再流行了,而且所有很酷的新功能和支持都在 Javascript less.js 项目上。如果您使用 PHP 或 .NET 进行操作,那么您应该分别检查这些项目。
Your syntax of your mixin is fine, and it compiles fine. I tried it out in my LESS converter and it's all good. I applied the rule to a page for an
a
tag selector:And it outputs:
which colors my links just like it sounds like it should.
What version of LESS are you compiling with - what platform and version of the complier? I wouldn't recommend the Ruby compiler as I don't think it's kept up much anymore, and all the cool new features and support are on the Javascript less.js project. If you're doing it in PHP or .NET then you should check with those projects respectively.