Bootstrap Hopper Width

in bootstrap-responsive.css

.row-fluid .span10{
    width: 91.45299145299145%;
    *width: 91.39979996362975%;
}

I set the size, but I'm curious how they printed these numbers and why are they accurate to 14 decimal places?

+5
source share
1 answer

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   // the point at which the navbar stops collapsing

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:

+12
source

All Articles