-
Notifications
You must be signed in to change notification settings - Fork 2
/
grid.less
121 lines (89 loc) · 2.63 KB
/
grid.less
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
* Fluid and Responsive Vertical Grid
*/
// Default grid, change to fit your requirements.
@columnWidth: 30;
@gutterWidth: 10;
@columns: 24;
@gridType: "float"; // "flex"
/**
* Namespace what could be namespaced
*/
#desinax-vgrid {
// Utility variable, you should never need to modify this
@gridSystemWidth: @columns * (@columnWidth + @gutterWidth) * 1px;
// Use % for fluid layout
@totalWidth: 100% / @gridSystemWidth;
/**
* Wrap grid in a container.
*/
.grid(@maxWidth) {
margin-right: auto;
margin-left: auto;
max-width: @maxWidth;
}
/**
* Show grid.
*/
.showGrid(@gridImage, @maxWidth: 100%) {
background: url("@{gridImage}") repeat-y scroll center center;
background-size: 100% auto;
@media (min-width: @maxWidth + 0px) {
background-size: @maxWidth auto;
}
}
/**
* All columns must be wrapped in a row.
*/
.row(@columns: @columns) when (@gridType = "float") {
display: block;
width: @totalWidth * (@gridSystemWidth + @gutterWidth);
}
.row(@columns: @columns) when (@gridType = "flex") {
display: flex;
flex-flow: row wrap;
}
.row(@columns: @columns) {
margin-left: -1 * @totalWidth * @gutterWidth / 2;
margin-right: -1 * @totalWidth * @gutterWidth / 2;
// Clearfix
&::after {
content: "";
display: block;
clear: both;
}
}
/**
* Create a column spanning @col columns.
*/
.column(@col, @columns: @columns) when (@gridType = "float") {
display: inline;
float: left;
}
.column(@col, @columns: @columns) when (@gridType = "flex") {
flex: 0 0 auto;
}
.column(@col, @columns: @columns) {
width: @totalWidth * (((@columnWidth + @gutterWidth) * @col ) - @gutterWidth);
margin-left: @totalWidth * @gutterWidth / 2;
margin-right: @totalWidth * @gutterWidth / 2;
}
/**
* Push a column @offset columns.
*/
.push(@offset: 1) {
margin-left: @totalWidth * @offset * (@gutterWidth + @columnWidth) + @totalWidth * @gutterWidth / 2;
}
/**
* Pull a column left @offset columns.
*/
.pull(@offset: 1) {
margin-left: -1 * @totalWidth * @offset * (@gutterWidth + @columnWidth) + @totalWidth * @gutterWidth / 2;
}
/**
* Pull a column right @offset columns.
*/
.pull-right(@offset: 1) {
margin-right: -1 * @totalWidth * @offset * (@gutterWidth + @columnWidth) + @totalWidth * @gutterWidth / 2;
}
}