Gaz*_*dge 9 php less twitter-bootstrap lessphp
我试图在编译之前覆盖一些bootstrap LESS变量
// Core variables
@import "variables.less";
// Trying to override @white from variables.less
@white: #de1de1;
// other bootstrap @imports....
Run Code Online (Sandbox Code Playgroud)
上面的代码没有覆盖@white,但如果我@white在variables.less文件的末尾添加,它可以正常工作.
看来变量只能在同一个文件中覆盖.但这对我来说没有意义,因为我认为LESS没有这样的工作.例如,其他@import文件(上面的代码中省略)使用该@white变量.如果他们能够在variables.less文件之外使用它,为什么我不能在文件外覆盖它?
我使用Less Php 0.3.9来编译我的代码.
注意:我刚刚尝试了以下代码:
// Core variables
@import "variables.less";
@import "variables-custom.less";
Run Code Online (Sandbox Code Playgroud)
现在值@white取自variables-custom.less(这有点解决了我的问题).它仍然无法解释为什么我的原始代码不起作用.会很感激的答案.
变量将按照您将导入设置为编译的顺序被覆盖(并可用)。
例如:
@import "variables.less"; //@white is set
@import "styles.less"; //UPDATED @white NOT available
@import "variables-custom.less"; //Update @white
@import "styles2.less"; //UPDATED @white available
Run Code Online (Sandbox Code Playgroud)
因此,只要确保如果您不打算使用variables.less而是使用variables-custom.less,请将其放在所有其他.less文件之前(当然除了variables.less)。
| 归档时间: |
|
| 查看次数: |
7673 次 |
| 最近记录: |