forked from hugeinc/flexboxgrid-sass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flexboxgrid.scss
216 lines (181 loc) · 4.26 KB
/
flexboxgrid.scss
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//
// -- Start editing -- //
//
@import "../sass-flex-mixin/_flex";
// Set the number of columns you want to use on your layout.
$grid-columns: 12 !default;
// Set the gutter between columns.
$gutter-width: 1rem !default;
// Set a margin for the container sides.
$outer-margin: 2rem !default;
// Create or remove breakpoints for your project
// Syntax:
// name SIZErem,
$breakpoints:
sm 48em 46rem,
md 62em 61rem,
lg 75em 71rem !default;
$flexboxgrid-max-width: 1200px !default;
//
// -- Stop editing -- //
//
$gutter-compensation: $gutter-width * .5 * -1;
$half-gutter-width: $gutter-width * .5;
.wrapper {
box-sizing: border-box;
max-width: $flexboxgrid-max-width;
margin: 0 auto;
}
.container-fluid {
margin-right: auto;
margin-left: auto;
padding-right: $outer-margin;
padding-left: $outer-margin;
}
.row {
box-sizing: border-box;
@include flexbox();
@include flex(0, 1, auto);
@include flex-direction(row);
@include flex-wrap(wrap);
margin-right: $gutter-compensation;
margin-left: $gutter-compensation;
}
.row.reverse {
@include flex-direction(row-reverse);
}
.col.reverse {
@include flex-direction(column-reverse);
}
@mixin flexboxgrid-sass-col-common {
box-sizing: border-box;
// split @include flex(0, 0, auto) into individual props
@include flex-grow(0);
@include flex-shrink(0);
// we leave @include flex-basis(auto) out of common because
// in some spots we need it and some we dont
// more why here: https://github.com/kristoferjoseph/flexboxgrid/issues/126
padding-right: $half-gutter-width;
padding-left: $half-gutter-width;
}
$name: xs;
.col-#{$name} {
@include flexboxgrid-sass-col-common;
@include flex-basis(auto);
}
@for $i from 1 through $grid-columns {
.col-#{$name}-#{$i} {
@include flexboxgrid-sass-col-common;
@include flex-basis(100% / $grid-columns * $i);
max-width: 100% / $grid-columns * $i;
}
}
@for $i from 1 through $grid-columns {
.col-#{$name}-offset-#{$i} {
@include flexboxgrid-sass-col-common;
margin-left: 100% / $grid-columns * $i;
}
}
.col-#{$name} {
@include flex-grow(1);
@include flex-basis(0);
max-width: 100%;
}
.start-#{$name} {
@include justify-content(flex-start);
text-align: start;
}
.center-#{$name} {
@include justify-content(center);
text-align: center;
}
.end-#{$name} {
@include justify-content(flex-end);
text-align: end;
}
.top-#{$name} {
@include align-items(flex-start);
}
.middle-#{$name} {
@include align-items(center);
}
.bottom-#{$name} {
@include align-items(flex-end);
}
.around-#{$name} {
@include justify-content(space-around);
}
.between-#{$name} {
@include justify-content(space-between);
}
.first-#{$name} {
order: -1;
}
.last-#{$name} {
order: 1;
}
@each $breakpoint in $breakpoints {
$name: nth($breakpoint, 1);
$size: nth($breakpoint, 2);
$container: nth($breakpoint, 3);
@media only screen and (min-width: $size) {
.container {
width: $container;
}
.col-#{$name} {
@include flexboxgrid-sass-col-common;
@include flex-basis(auto);
}
@for $i from 1 through $grid-columns {
.col-#{$name}-#{$i} {
@include flexboxgrid-sass-col-common;
@include flex-basis(100% / $grid-columns * $i);
max-width: 100% / $grid-columns * $i;
}
}
@for $i from 1 through $grid-columns {
.col-#{$name}-offset-#{$i} {
@include flexboxgrid-sass-col-common;
margin-left: 100% / $grid-columns * $i
}
}
.col-#{$name} {
@include flex-grow(1);
@include flex-basis(0);
max-width: 100%;
}
.start-#{$name} {
@include justify-content(flex-start);
text-align: start;
}
.center-#{$name} {
@include justify-content(center);
text-align: center;
}
.end-#{$name} {
@include justify-content(flex-end);
text-align: end;
}
.top-#{$name} {
@include align-items(flex-start);
}
.middle-#{$name} {
@include align-items(center);
}
.bottom-#{$name} {
@include align-items(flex-end);
}
.around-#{$name} {
@include justify-content(space-around);
}
.between-#{$name} {
@include justify-content(space-between);
}
.first-#{$name} {
order: -1;
}
.last-#{$name} {
order: 1;
}
}
}