2
我的CSS工作表需要重置一些Bootstrap 3預設值以使我想要的風格,因此我需要像.m-b-0
設置margin-bottom:0px
公用事業類。我用的是在咕嚕不會承認喜歡.m-b-1
和.m-b-10
由循環產生,當我在其他類嵌套類他們.m-b-0
,但類爲什麼LESS編譯器無法識別由零迭代器生成的類?
但不編譯器將被正確識別。
在我減檔的循環代碼是這樣的:
.m-loop (@i) when (@i <= @iterations) {
[email protected]{i}{
margin: ~"@{i}px";
}
[email protected]{i}{
margin-left: ~"@{i}px";
margin-right: ~"@{i}px";
}
[email protected]{i}{
margin-top: ~"@{i}px";
margin-bottom: ~"@{i}px";
}
[email protected]{i}{
margin-left: ~"@{i}px";
}
[email protected]{i}{
margin-right: ~"@{i}px";
}
[email protected]{i}{
margin-top: ~"@{i}px";
}
[email protected]{i}{
margin-bottom: ~"@{i}px";
}
.m-loop(@i + 1);
}
.m-loop(0);
,我使用應該在同一個不太文件中生成的類是這樣的:
.panel{
.m-b-0;
}
然後我的編譯器扔
Running "less:production" (less) task
>> NameError: .m-b-0 is undefined in ../css/less/stylesheet.less on line 237, column 3:
>> 236 div.panel{
>> 237 .m-b-0;
>> 238 }
Warning: Error compiling ../css/less/stylesheet.less Used --force, continuing.
這是禁止使用零值迭代器在少編譯或我在哪裏tak它錯了嗎?謝謝!
對不起,但它是一個編輯問題。循環代碼正在運行。它生成了所需的CSS,但當我通過mixin/nesting在相同的LESS文件中使用生成的類時會失敗。 –