CSS Less v1.5.0 , , .
@add-margin: true;
body when (@add-margin){
margin-top: 20px;
}
, , , &.
& when (@add-margin){
body{
margin-top: 20px;
}
h1{
margin-top: 10px;
}
}
Note: As mentioned in the comments of memeLab , any value for a variable @add-marginother than trueis equally considered false . This is due to what trueis the keyword, whereas 'true'is the value of String. For example, the following will not produce anything.
@add-margin: 'true';
body when (@add-margin){
margin-top: 20px;
}
However, the following will work because it compares strings.
@add-margin: 'true';
body when (@add-margin = 'true'){
margin-top: 20px;
}
If you use a smaller compiler lower than v1.5.0, then Unicornist would be the best answer .
source
share