.spanBorder 是一个“函数”,您还必须对它进行.spanBorderX
调用:.spanBorderX (@gridColumns);
请参阅 .core 的完整代码(默认网格):
.core (@gridColumnWidth, @gridGutterWidth) {
.spanX (@index) when (@index > 0) {
.span@{index} { .span(@index); }
.spanX(@index - 1);
}
.spanX (0) {}
.spanBorderX (@index) when (@index > 0) {
.spanBorder@{index} { .spanBorder(@index); }
.spanBorderX(@index - 1);
}
.spanBorderX (0) {}
.offsetX (@index) when (@index > 0) {
.offset@{index} { .offset(@index); }
.offsetX(@index - 1);
}
.offsetX (0) {}
.offset (@columns) {
margin-left: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns + 1));
}
.span (@columns) {
width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1));
}
.spanBorder (@columns) {
width: ((@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1))) - 1;
}
.row {
margin-left: @gridGutterWidth * -1;
.clearfix();
}
[class*="span"] {
float: left;
min-height: 1px; // prevent collapsing columns
margin-left: @gridGutterWidth;
}
// Set the container width, and override it for fixed navbars in media queries
.container,
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container { .span(@gridColumns); }
// generate .spanX, .spanBorderX and .offsetX
.spanX (@gridColumns);
.spanBorderX (@gridColumns);
.offsetX (@gridColumns);
}
重新编译后将此代码添加到 mixins.less 您现在可以使用:
<div class="row"><div class="spanBorder6" style="background-color:red;border-left:1px solid blue;">test</div><div class="spanBorder6" style="background-color:red;border-left:1px solid blue;">test</div></div>
当然 spanBorder1、spanBorder2 等也可以。