Blame view

src/styles/mixins/layout.less 1.74 KB
7fa943eb   梁灏   init
1
2
3
4
  @row-prefix-cls: ~"@{css-prefix}row";
  @col-prefix-cls: ~"@{css-prefix}col";
  
  .make-row(@gutter: @grid-gutter-width) {
4dfacfca   梁灏   publish Tooltip c...
5
      position: relative;
7fa943eb   梁灏   init
6
7
8
9
10
11
      margin-left: (@gutter / -2);
      margin-right: (@gutter / -2);
      height: auto;
      .clearfix;
  }
  
84a351df   梁灏   Layout support re...
12
  .float-grid-columns(@class) {
7fa943eb   梁灏   init
13
      .col(@index) { // initial
84a351df   梁灏   Layout support re...
14
          @item: ~".@{col-prefix-cls}-span@{class}-@{index}";
7fa943eb   梁灏   init
15
16
17
          .col((@index + 1), @item);
      }
      .col(@index, @list) when (@index =< @grid-columns) { // general
84a351df   梁灏   Layout support re...
18
          @item: ~".@{col-prefix-cls}-span@{class}-@{index}";
7fa943eb   梁灏   init
19
20
21
22
23
24
25
26
27
28
29
          .col((@index + 1), ~"@{list}, @{item}");
      }
      .col(@index, @list) when (@index > @grid-columns) { // terminal
          @{list} {
              float: left;
              flex: 0 0 auto;
          }
      }
      .col(1); // kickstart it
  }
  
84a351df   梁灏   Layout support re...
30
31
  .loop-grid-columns(@index, @class) when (@index > 0) {
      .@{col-prefix-cls}-span@{class}-@{index} {
7fa943eb   梁灏   init
32
33
34
          display: block;
          width: percentage((@index / @grid-columns));
      }
84a351df   梁灏   Layout support re...
35
      .@{col-prefix-cls}@{class}-push-@{index} {
7fa943eb   梁灏   init
36
37
          left: percentage((@index / @grid-columns));
      }
84a351df   梁灏   Layout support re...
38
      .@{col-prefix-cls}@{class}-pull-@{index} {
7fa943eb   梁灏   init
39
40
          right: percentage((@index / @grid-columns));
      }
84a351df   梁灏   Layout support re...
41
      .@{col-prefix-cls}@{class}-offset-@{index} {
7fa943eb   梁灏   init
42
43
          margin-left: percentage((@index / @grid-columns));
      }
84a351df   梁灏   Layout support re...
44
      .@{col-prefix-cls}@{class}-order-@{index} {
7fa943eb   梁灏   init
45
46
          order: @index;
      }
84a351df   梁灏   Layout support re...
47
      .loop-grid-columns((@index - 1), @class);
7fa943eb   梁灏   init
48
49
  }
  
84a351df   梁灏   Layout support re...
50
51
  .loop-grid-columns(@index, @class) when (@index = 0) {
      .@{col-prefix-cls}@{class}-@{index} {
7fa943eb   梁灏   init
52
53
54
55
56
57
58
59
60
61
          display: none;
      }
      .@{col-prefix-cls}-push-@{index} {
          left: auto;
      }
      .@{col-prefix-cls}-pull-@{index} {
          right: auto;
      }
  }
  
84a351df   梁灏   Layout support re...
62
63
64
  .make-grid(@class: ~'') {
      .float-grid-columns(@class);
      .loop-grid-columns(@grid-columns, @class);
7fa943eb   梁灏   init
65
  }