They start with three values ββthat can be defined by the user:
@gridColumns: 12;
@gridColumnWidth: 60px;
@gridGutterWidth: 20px;
Edit: in Bootstrap 3.0+, now the variables are:
@grid-columns
@grid-gutter-width
@grid-float-breakpoint
And calculate the width of the fixed row:
@gridRowWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));
Then they flow:
@fluidGridColumnWidth: percentage(@gridColumnWidth/@gridRowWidth);
@fluidGridGutterWidth: percentage(@gridGutterWidth/@gridRowWidth);
Finally, generate all the gaps (this is a bit confusing):
.spanX (@index) when (@index > 0) {
(~".span@{index}") { .span(@index); }
.spanX(@index - 1);
}
.span (@columns) {
width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1));
*width: (@fluidGridColumnWidth * @columns) + (@fluidGridGutterWidth * (@columns - 1)) - (.5 / @gridRowWidth * 100 * 1%);
}
.row-fluid {
// generate .spanX and .offsetX
.spanX (@gridColumns);
.offsetX (@gridColumns);
}
As you can see, LESS does division and multiplication.
See for yourself:
source
share