/
waffle-grid.scss
149 lines (119 loc) · 3.4 KB
/
waffle-grid.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
/*!
* waffle-grid - v1.2.2 - (https://lucasgruwez.github.io/waffle-grid)
* Copyright 2017 Lucas Gruwez.
* Licensed under MIT
* https://lucasgruwez.github.io/waffle-grid
*/
// Class names
// Change them to whatever you're used to
$grid-classname: "grid" !default;
$row-classname: "row" !default;
$column-classname: "col" !default;
// Column amounts, results in:
// .col-n-of-4, or .col-n-of-8
$grid-columns: (4, 8, 12) !default;
// Column amounts for medium devices
$m-columns: (4, 6, 8) !default;
// Column amounts for small devices
$s-columns: (4, 6) !default;
// Gutter width
$gutter-width: 20px !default;
// Grid width and max-width.
// It is automatically centered on the page.
$grid-width: 960px !default;
$grid-max-width: 80% !default;
// Pushes and Pulls
$pushes: true !default;
$pulls: true !default;
// Breakpoints
$bp-medium: 840px !default;
$bp-small: 480px !default;
// Actual css, change at your own risk
.#{$grid-classname} {
display: flex;
flex-direction: column;
width: $grid-width;
max-width: $grid-max-width;
margin: 0 auto;
}
.#{$row-classname} {
display: flex;
flex-direction: row;
width: 100%;
flex-wrap: wrap;
}
.#{$column-classname} {
box-sizing: border-box;
margin: $gutter-width / 2;
vertical-align: top;
}
.center {margin-left: auto; margin-right: auto;}
.left {margin-right: auto;}
.right {margin-left: auto;}
@each $col-am in $grid-columns {
@for $i from 1 through $col-am {
.#{$column-classname}-#{$i}-of-#{$col-am} {
width: calc(#{percentage($i/$col-am)} - #{$gutter-width});
} // end width
@if ($pushes) {
.push-#{$i}-of-#{$col-am} {
margin-left: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pushes
@if ($pulls) {
.pull-#{$i}-of-#{$col-am} {
margin-right: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pulls
} // end for
} // end each
@media (max-width: $bp-medium) {
.l-only {display: none;}
.m-hide {display: none;}
@each $col-am in $m-columns {
@for $i from 1 through $col-am {
.#{$column-classname}-m-#{$i}-of-#{$col-am} {
width: calc(#{percentage($i/$col-am)} - #{$gutter-width});
} // end width
@if ($pushes) {
.push-m-#{$i}-of-#{$col-am} {
margin-left: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pushes
@if ($pulls) {
.pull-m-#{$i}-of-#{$col-am} {
margin-right: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pulls
} // end for
} // end each
}
@media (max-width: $bp-small) {
.s-hide {display: none;}
@each $col-am in $s-columns {
@for $i from 1 through $col-am {
.#{$column-classname}-s-#{$i}-of-#{$col-am} {
width: calc(#{percentage($i/$col-am)} - #{$gutter-width});
} // end width
@if ($pushes) {
.push-s-#{$i}-of-#{$col-am} {
margin-left: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pushes
@if ($pulls) {
.pull-s-#{$i}-of-#{$col-am} {
margin-right: calc(#{percentage($i/$col-am)} + #{$gutter-width} / 2);
}
} // end pulls
} // end for
} // end each
}
@media (min-width: $bp-small) {
.s-only {display: none;}
.s-and-lower {display: none;}
}
@media (min-width: $bp-medium) {
.m-only {display: none;}
.m-and-lower {display: none;}
}
// under 150 lines !!