开发者

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

开发者 https://www.devze.com 2023-04-13 05:24 出处:网络
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
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

精彩评论

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

关注公众号