Skip to content

Instantly share code, notes, and snippets.

@ivanbanov
Last active August 29, 2015 14:23
Show Gist options
  • Save ivanbanov/6e62591c218e5317d20e to your computer and use it in GitHub Desktop.
Save ivanbanov/6e62591c218e5317d20e to your computer and use it in GitHub Desktop.
Responsive grid focused on mobile first
// BREAKPOINTS
// https://jdsteinbach.com/css/sass-maps-breakpoint-mixin/
$breakpoints: (
small : 320px,
medium: 768px,
large : 992px,
wide : 1400px
);
$columns: 12;
$gutter : 1em;
@mixin media( $size ) {
@if not map-has-key( $breakpoints, $size ) {
@warn "Warning: `#{$size}` is not a valid breakpoint name.";
} @else {
@media ( min-width: map-get( $breakpoints, $size ) ) {
@content;
}
}
}
@mixin column( $size, $cols ) {
.#{$size}-#{$cols} {
width: ( $cols * 100 / $columns ) + %;
}
}
.clearfix {
&:before,
&:after {
content: "";
display: table;
clear: both;
}
}
.row {
@extend .clearfix;
&.reverse .column {
float: right;
}
}
.column {
padding: 0 $gutter;
float: left;
width: 100%;
}
@each $size, $value in ( $breakpoints ) {
@include media( $size ) {
@for $i from 1 through $columns {
@include column( $size, $i );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment