0

我正在尝试在 LESS 中创建一个包含多个变量的 mixin,但由于某种原因它不起作用。我有这个少:

.rgbabg(@r: 0, @g: 0, @b: 0, @a: .5) {
  @val: rgba(@r, @g, @b, @a);

  background: @val;
}

我这样称呼它:

.rgbabg(255, 0, 0, .5);

但是我根本没有任何关于我的元素的背景。我的语法好吗?

4

1 回答 1

3

你的 mixin 的语法很好,而且编译得很好。我在我的LESS 转换器中试了一下,一切都很好。我将规则应用于a标签选择器的页面:

a {
  .rgbabg(255);
}

它输出:

a {
  background: rgba(255, 0, 0, 0.5);
}

就像听起来应该的那样为我的链接着色。

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.

于 2011-09-21T20:15:42.860 回答