Skip to content

Instantly share code, notes, and snippets.

@rendfall
Created May 21, 2017 23:10
Show Gist options
  • Save rendfall/6cd7687008baf280c8c69efcb3d1b149 to your computer and use it in GitHub Desktop.
Save rendfall/6cd7687008baf280c8c69efcb3d1b149 to your computer and use it in GitHub Desktop.
Simple flexbox grid
@mixin element($e) {
&__#{$e} { @content; }
}
@mixin modifier($e) {
&--#{$e} { @content; }
}
.grid {
$gutter: 30px;
$items-in-row: 2;
$basis: 100% * (1 / $items-in-row);
@include element('row') {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
margin-left: -1 * $gutter;
margin-right: -1 * $gutter;
}
@include element('item') {
flex: 1 0 $basis;
padding: 0 $gutter;
@include modifier('pull-top') {
align-self: flex-start;
}
@include modifier('pull-bottom') {
align-self: flex-end;
}
@include modifier('pull-middle') {
align-self: center;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment