开发者

Does SASS or LESS support variable mixin arguments? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 7 years ago.

开发者_如何转开发 Improve this question

Something like (contrived LESS example):

.bg() {
    background: (@arguments);
}

#blah{
    .background(red, url('blah'))
    .background(blue)
}

Cheers


This does work in LESSCSS, but you have 2 errors in your code. First, missing semicolons for statement terminators. Second, you defined a .bg() mixin but tried to reference it as .background(). Try this:

.bg() {
    background: (@arguments);
}

#blah{
    .bg(red, url('blah'));
    .bg(blue);
}

The output is exactly like you would expect:

#blah {
  background: red url('blah');
  background: blue;
}

You can run code samples to see if and how things like this compile in LESS CSS using my LESS javascript-based converter (files on GitHub), or just follow the LESSCSS client-side usage instructions to see it working on your own pages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜