bootstrap fluid row width

后端 未结 1 1474
耶瑟儿~
耶瑟儿~ 2020-12-10 17:58

in bootstrap-responsive.css

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

I was configuring the siz

相关标签:
1条回答
  • 2020-12-10 18:59

    They start with three values, which can be user-defined:

    @gridColumns: 12;
    @gridColumnWidth: 60px;
    @gridGutterWidth: 20px;
    

    Edit: on Bootstrap 3.0+, the variables are now:

    @grid-columns
    @grid-gutter-width
    @grid-float-breakpoint   // the point at which the navbar stops collapsing
    

    And calculate fixed row width:

    @gridRowWidth: (@gridColumns * @gridColumnWidth) + (@gridGutterWidth * (@gridColumns - 1));
    

    Then they go fluid:

    @fluidGridColumnWidth: percentage(@gridColumnWidth/@gridRowWidth);
    @fluidGridGutterWidth: percentage(@gridGutterWidth/@gridRowWidth);
    

    And finaly, generate all the spans (that 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 see, LESS does the divisions and multiplications.

    See it yourself:

    1. https://github.com/twitter/bootstrap/blob/master/less/variables.less
    2. https://github.com/twitter/bootstrap/blob/master/less/mixins.less
    0 讨论(0)
提交回复
热议问题