예, 가능합니다. 한 번 해결해야 할 버그가있었습니다.
예 LESS 코드
//Set up guarded mixins
.setHeight(@h) when (ispercentage(@h)) {
@height: 1024px;
}
.setHeight(@h) when not (ispercentage(@h)) {
@height: @h;
}
//set up main height
@mainHeight: 50%;
body { height: @mainHeight;}
//call it by itself to make global
//.setHeight(@mainHeight); <-this failed (appears to be a bug)
.setHeight(50%); // <-this worked
.subsection { height: @height; /* just to show it is setting it */}
//use it for other globals
@textAreaHeight: 0.5 * @height;
@buttonHeight: 0.2 * @height;
textarea { height: @textAreaHeight}
button { height: @buttonHeight}
//override it locally
body.fixedHeight {
.setHeight(300px);
@textAreaHeight: 0.333 * @height;
height: @height;
textarea { height: @textAreaHeight}
}
예 CSS의 출력은
body {
height: 50%;
}
.subsection {
height: 1024px; /* just to show it is setting it */
}
textarea {
height: 512px;
}
button {
height: 204.8px;
}
body.fixedHeight {
height: 300px;
}
body.fixedHeight textarea {
height: 99.9px;
}
당신은 사용해야은 : 대신에 = 기호의,하지만 당신은 이미 알고 있었다. –