编译Twitter的Bootstrap 2.3.2时。用更少的2我发现以下错误:
NameError: #grid > .core > .span is undefined in /home/bootstrap-2.3.2/less/navbar.less on line 199, column 3:
198 .navbar-fixed-bottom .container {
199 #grid > .core > .span(@gridColumns);
200 }
我该如何解决?
通过创建在Bootstrap mixins之后加载的新mixin,我无需修改Bootstrap文件就可以避免错误:
#grid {
.core {
.span(@gridColumns) {
width: (@gridColumnWidth * @gridColumns) + (@gridGutterWidth * (@gridColumns - 1));
}
}
};
这对我们来说更好,因为我们避免修补contrib软件包。
在less/navbar.less
文件中:
替换:
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
#grid > .core > .span(@gridColumns);
}
使用:
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
width: (@gridColumnWidth * @gridColumns) + (@gridGutterWidth * (@gridColumns - 1));
}
无需编辑样式。
仅npm install [email protected]
,您将拥有最新的less v1的本地(在您所在的文件夹中)副本,如果您运行node_modules/less/bin/lessc source.less output.css
,它将正确编译bootstrap v2.3.2。
这里是一个补丁程序,应该在bootstrap和lessc 3.10.3的v2.0.3中执行此操作:
--- a/bootstrap/less/mixins.less
+++ b/bootstrap/less/mixins.less
@@ -530,16 +530,16 @@
// The Grid
#grid {
- .core (@gridColumnWidth, @gridGutterWidth) {
+ .core (@gridColumnWidth: @gridColumnWidth, @gridGutterWidth: @gutterColumnWidth) {
.spanX (@index) when (@index > 0) {
- (~".span@{index}") { .span(@index); }
+ .span@{index} { .span(@index); }
.spanX(@index - 1);
}
.spanX (0) {}
.offsetX (@index) when (@index > 0) {
- (~".offset@{index}") { .offset(@index); }
+ .offset@{index} { .offset(@index); }
.offsetX(@index - 1);
}
.offsetX (0) {}
@@ -576,7 +576,7 @@
.fluid (@fluidGridColumnWidth, @fluidGridGutterWidth) {
.spanX (@index) when (@index > 0) {
- (~".span@{index}") { .span(@index); }
+ .span@{index} { .span(@index); }
.spanX(@index - 1);
}
.spanX (0) {}
@@ -608,7 +608,7 @@
.input(@gridColumnWidth, @gridGutterWidth) {
.spanX (@index) when (@index > 0) {
- (~"input.span@{index}, textarea.span@{index}, .uneditable-input.span@{index}") { .span(@index); }
+ input.span@{index}, textarea.span@{index}, .uneditable-input.span@{index} { .span(@index); }
.spanX(@index - 1);
}
.spanX (0) {}