-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtiny-grid.scss
104 lines (88 loc) · 2.63 KB
/
tiny-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
// Tiny Grid by @alexerlandsson
// https://alexerlandsson.com
// This is a CSS grid system used to build responsive websites
// and applications. For documentation, check out the GitHub repository:
// https://github.com/alexerlandsson/tiny-grid
@use 'sass:math';
@mixin tiny-grid {
// Settings
$grid-columns: 12 !default;
$grid-gutter: 20px !default;
$grid-container-max-width: 1470px !default;
$grid-container-gutter: 40px !default;
// To prefix all our output classes, add a prefix here
$grid-prefix: "pdac-";
$grid-breakpoints: (
sm: 600px,
md: 900px,
lg: 1200px,
xl: 1800px
) !default;
// Container Elements
%container-base {
margin-left: auto;
margin-right: auto;
width: 100%;
padding-left: $grid-container-gutter;
padding-right: $grid-container-gutter;
box-sizing: border-box;
}
.#{$grid-prefix}container {
@extend %container-base;
max-width: $grid-container-max-width;
}
.#{$grid-prefix}container-fluid {
@extend %container-base;
}
.#{$grid-prefix}row {
margin-left: math.div($grid-gutter, -2);
margin-right: math.div($grid-gutter, -2);
box-sizing: border-box;
font-size: 0;
> * {
font-size: 1rem;
}
}
// Columns
[class^="#{$grid-prefix}col-"],
[class*=" #{$grid-prefix}col-"] {
display: inline-block;
vertical-align: top;
width: 100%;
min-height: 1px;
padding-left: math.div($grid-gutter, 2);
padding-right: math.div($grid-gutter, 2);
box-sizing: border-box;
}
// Create non-breakpoint specific columns and column offsets
@for $i from 1 through $grid-columns {
.#{$grid-prefix}col-#{$i} {
width: (math.div(100%, $grid-columns) * $i);
}
.#{$grid-prefix}col-offset-#{$i} {
margin-left: (math.div(100%, $grid-columns) * $i);
}
}
// Create breakpoint specific columns
@each $breakpoint-name in map-keys($grid-breakpoints) {
// Get each key's value
$breakpoint-width: map-get($grid-breakpoints, $breakpoint-name);
// Create media query for each breakpoint
@media (min-width: $breakpoint-width) {
// Add offset-0 to reset offset in specific breakpoints
.#{$grid-prefix}col-#{$breakpoint-name}-offset-0 {
margin-left: 0;
}
// Create columns and column offsets for each size in this breakpoint
@for $i from 1 through $grid-columns {
.#{$grid-prefix}col-#{$breakpoint-name}-#{$i} {
width: (math.div(100%, $grid-columns) * $i);
}
.#{$grid-prefix}col-#{$breakpoint-name}-offset-#{$i} {
margin-left: (math.div(100%, $grid-columns) * $i);
}
}
}
}
}
@include tiny-grid;