Last active
July 25, 2018 09:47
-
-
Save Twikito/27a252f08d70dbba8544446f384a13ce to your computer and use it in GitHub Desktop.
Ultimate grid system
This file contains 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
$global-gutters: 2rem; | |
$wrapper-width : 96rem; |
This file contains 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
[class*=' grid-'], | |
[class^='grid-'] { | |
--grid-item-min-width: 1fr; | |
display: grid; | |
grid-template-columns: repeat( auto-fill, minmax( var(--grid-item-min-width), 1fr ) ); | |
grid-gap: $global-gutters $global-gutters; grid-auto-flow: row dense; justify-items: stretch; align-items: stretch; | |
// To deal with overflows | |
& > * { | |
min-width: 0; | |
} | |
} | |
// This let you create a grid in any context | |
@mixin grid($from, $to, $width, $scope: '') { | |
@for $i from $from through $to { | |
$a: ($width / $i) - $global-gutters; | |
@include media('>#{$a}') { | |
#{$scope} .grid-#{$i} { | |
--grid-item-min-width: #{$a}; | |
} | |
} | |
} | |
} | |
@include grid(1, 4, $wrapper-width, '.wrapper'); | |
.grid-item-full { | |
grid-column: 1 / -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment