Skip to content

Instantly share code, notes, and snippets.

@alexgleason
Created February 1, 2016 04:35
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save alexgleason/382560042f94c6d25056 to your computer and use it in GitHub Desktop.
Save alexgleason/382560042f94c6d25056 to your computer and use it in GitHub Desktop.
Bourbon/Neat Flexbox Grid
/*
Based on code by Kevin Lamping
source: http://codepen.io/klamping/pen/waMOeX
*/
@mixin flex-grid {
display: flex;
flex-wrap: wrap;
margin-left: -$gutter;
margin-top: -$gutter;
}
@mixin flex-item($min-width, $max-cols) {
flex: 1 0 $min-width;
margin-left: $gutter;
margin-top: $gutter;
box-sizing: border-box;
@for $i from 2 through $max-cols {
$screen-width: ($min-width*$i)+($gutter*$i);
$column-width: (100%/$i);
@media (min-width: $screen-width) {
max-width: calc(#{$column-width} - #{$gutter});
}
}
$column-width: (100%/$max-cols);
@media (min-width: $min-width*$max-cols) {
min-width: calc(#{$column-width} - #{$gutter});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment