Last active
August 29, 2021 21:15
-
-
Save aronhoyer/6d3941010202d271b7313aeb4bf497ac to your computer and use it in GitHub Desktop.
SASS grid system with CSS grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$screen-sizes: ( | |
xxl: 1920px, | |
xl: 1440px, | |
l: 1360px, | |
ml: 1280px, | |
m: 768px, | |
s: 576px | |
); | |
$col-count: 24; | |
@for $col from 1 through $col-count { | |
.col--span\:#{$col} { | |
grid-column-start: span $col; | |
@for $i from 0 through ($col-count - 1) { | |
&.col--offset\:#{$i} { | |
grid-column: ($i + 1) / span $col; | |
} | |
} | |
&.col--center { | |
grid-column: (($col-count - $col) / 2 + 1) / span $col; | |
} | |
} | |
} | |
@each $label, $size in $screen-sizes { | |
@for $col from 1 through $col-count { | |
@media (max-width: $size) { | |
.#{$label}-col--span\:#{$col} { | |
grid-column-start: span $col; | |
@for $i from 0 through ($col-count - 1) { | |
&.#{$label}-col--offset\:#{$i} { | |
grid-column: ($i + 1) / span $col; | |
} | |
} | |
&.#{$label}-col--center { | |
grid-column: (($col-count - $col) / 2 + 1) / span $col; | |
} | |
} | |
} | |
} | |
} | |
.grid { | |
display: grid; | |
grid-template-columns: repeat($col-count, 1fr); | |
grid-column-gap: 30px; | |
} |
lol I was sleeping at my work. O boy
.
o boy.
it was a long day.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool dudes