zxl
2026-03-25 d29d77e91951e30abba6596359b138bc4c6ac108
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
 * author: lilinchang
 * less函数生成flex相关常用类名
 */
.flex {
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-align-items: center;
  align-items: center;
  flex-wrap: nowrap;
}
 
.flex-shrink-0 {
  -webkit-flex-shrink: 0;
  flex-shrink: 0;
}
 
// 生成justify-content类 开始
@justifyContentNameList: center, start, end, between, around, initial, inherit;
@justifyContentList: center, flex-start, flex-end, space-between, space-around, initial, inherit;
 
.justifyContent(@className, @value) {
  .flex-@{className} {
    -webkit-justify-content: @value;
    justify-content: @value;
  }
}
 
.loopJustifyContent(@i) when (@i < length(@justifyContentNameList) + 1 ) {
  .justifyContent(extract(@justifyContentNameList, @i), extract(@justifyContentList, @i));
  .loopJustifyContent(@i+1);
}
 
.loopJustifyContent(1);
// 生成justify-content类 结束
 
// 生成align-items,align-self类 开始
@alignNameList: stretch, center, start, end, baseline, initial, inherit;
@alignList: stretch, center, flex-start, flex-end, baseline, initial, inherit;
 
.align(@className, @value) {
  .flex-align-@{className} {
    -webkit-align-items: @value;
    align-items: @value;
  }
  .flex-self-@{className} {
    align-self: @value;
  }
}
 
.loopAlign(@i) when (@i < length(@alignNameList) + 1 ) {
  .align(extract(@alignNameList, @i), extract(@alignList, @i));
  .loopAlign(@i+1);
}
 
.loopAlign(1);
// 生成align-items,align-self类 结束
 
// 生成direction类 开始
@directionNameList: row, row-reverse, column, column-reverse, direction-initial, direction-inherit;
@directionList: row, row-reverse, column, column-reverse, initial, inherit;
 
.direction(@className, @value) {
  .flex-@{className} {
    -webkit-flex-direction: @value;
    flex-direction: @value;
  }
}
 
.loopDirection(@i) when (@i < length(@directionNameList) + 1 ) {
  .direction(extract(@directionNameList, @i), extract(@directionList, @i));
  .loopDirection(@i+1);
}
 
.loopDirection(1);
// 生成direction类 结束
 
// 生成wrap类 开始
@wrapNameList: nowrap, wrap, wrap-reverse, wrap-initial, wrap-inherit;
@wrapList: nowrap, wrap, wrap-reverse, initial, inherit;
 
.wrap(@className, @value) {
  .flex-@{className} {
    flex-wrap: @value;
  }
}
 
.loopWrap(@i) when (@i < length(@wrapNameList) + 1 ) {
  .wrap(extract(@wrapNameList, @i), extract(@wrapList, @i));
  .loopWrap(@i+1);
}
 
.loopWrap(1);
// 生成wrap类 开始