1
我用Lesscss在客户端使用它编写我的CSS(使用编译器less.js)。Lesscss与守卫混合。语法错误
在文档中有很多守卫用法的例子,但它不适用于我。我不明白,为什么...
代码示例放在这里:
@import "common-functions.less";
// variables
@minHeaderWidth: auto;
@maxHeaderWidth: 1200px;
@minButtonsWidth: 50px;
@maxButtonsWidth: 75px;
// Mixins with guards
.applyHeaderStyles(@headerWidth, @buttonsWidth) when (ispixel(@headerWidth)) {
.my-headerElement {
width: @headerWidth;
}
}
.applyHeaderStyles(@headerWidth, @buttonsWidth) when not (ispixel(@headerWidth)) {
.my-headerElement {
width: @headerWidth;
margin: 0 @buttonsWidth;
}
}
// than I use .applyHeaderWidth in @media queries
@media screen and (min-width: 1050px) {
.applyHeaderStyles(@maxHeaderWidth, @maxButtonsWidth);
.my-buttonElement {width: @maxButtonsWidth;}
}
@media screen and (max-width: 1049px) {
.applyHeaderStyles(@minHeaderWidth, @minButtonsWidth);
.my-buttonElement {width: @minButtonsWidth;}
}
代码是由文档writen。但它不起作用。 当我执行这个代码,我有语法错误:
Syntax Error on line 10 [link to my file] on line 10, column 58: 10 // Mixins with guards 11 .applyHeaderStyles(@headerWidth, @buttonsWidth) when (ispixel(@headerWidth)) { 12 .my-headerElement {
我已经less.js版本更新至1.2.2。现在它起作用了。 通过链接发现的答案: http://stackoverflow.com/questions/9491716/less-js-guards-and-conditionals – VikomiC 2012-03-09 12:16:59
如果您自己找出答案,建议您自己发布答案并接受答案或标题中标题为'已解决'的问题。欢迎来到SO !. – 2012-03-10 07:34:11