Last active
January 18, 2018 18:37
-
-
Save azinasili/f6d4a4b577d3ae3096137487f500ef3d to your computer and use it in GitHub Desktop.
Create the simplest grid possible using CSS Grid syntax
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
// Create the simplest grid possible using CSS Grid syntax | |
// Customize your grid with custom number of items, classnames, and gaps | |
// | |
// Example HTML | |
// <div class="row row-3"> | |
// <div class="col-1"></div> | |
// <div class="col-1"></div> | |
// <div class="col-1"></div> | |
// </div> | |
$SassGrid: ( | |
numberOfColumns: 10, | |
rowClassName: 'row', | |
colClassName: 'col', | |
gridGap: 1em, | |
); | |
.#{map-get($SassGrid, rowClassName)} { | |
display: grid; | |
grid-template-rows: auto; | |
grid-gap: map-get($SassGrid, gridGap); | |
} | |
@for $i from 1 through map-get($SassGrid, numberOfColumns) { | |
.#{map-get($SassGrid, rowClassName)}-#{$i} { | |
grid-template-columns: repeat($i, 1fr); | |
} | |
.#{map-get($SassGrid, colClassName)}-#{$i} { | |
grid-column: span $i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment