Less v2不能编译Twitter的Bootstrap 2.x.

Bas*_*sen 33 less twitter-bootstrap twitter-bootstrap-2

编译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 }
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

小智 59

我可以通过创建一个在Bootstrap mixins之后加载的新mixin来避免错误而不修改Bootstrap文件:

#grid {
    .core  {
        .span(@gridColumns) {
            width: (@gridColumnWidth * @gridColumns) + (@gridGutterWidth * (@gridColumns - 1));
        }
    }
};
Run Code Online (Sandbox Code Playgroud)

这对我们来说更好,因为我们避免修补contrib包.

  • 您永远不应该更改外部库/包的源文件.这就是你应该使用这个解决方案的原因. (2认同)

Bas*_*sen 42

less/navbar.less文件中:

更换:

.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
  #grid > .core > .span(@gridColumns);
}
Run Code Online (Sandbox Code Playgroud)

附:

.navbar-static-top .container,  
.navbar-fixed-top .container,
.navbar-fixed-bottom .container { 
width: (@gridColumnWidth * @gridColumns) + (@gridGutterWidth * (@gridColumns - 1));
}
Run Code Online (Sandbox Code Playgroud)

另请参阅:使用Less覆盖类定义