Skip to content

Instantly share code, notes, and snippets.

@stagfoo
Last active March 5, 2017 09:04
Show Gist options
  • Save stagfoo/98218c447f1d39093dac685e0a7ff2dc to your computer and use it in GitHub Desktop.
Save stagfoo/98218c447f1d39093dac685e0a7ff2dc to your computer and use it in GitHub Desktop.
Really small and Simple Sass Grid system
[class*='col-'] {
//Aligns the columns next to each other
width: 100%;
float:left;
min-height: 1px;
}
// an extend only class for clearfixing
%clearfix {
*zoom: 1;
&:before,
&:after { content: " "; display: table;}
&:after { clear: both;}
}
//simple container add media queries if you need them.
.container {
width:1140px;
margin:0 auto;
@extend %clearfix;
}
@mixin col($col, $sum) {
//mixin for naming convention and column maths
width: percentage($col/$sum);
display: inline-block;
@media only screen and (max-width: 768px) {
// change this or add more for each screen size
width: 100%;
}
}
//Loop through all columns
$col_num: 12;
@for $i from 1 through $col_num {
$name: xs;
.col-#{$name}-#{$i}{ @include col($i, $col_num);}
$name: sm;
.col-#{$name}-#{$i}{ @include col($i, $col_num);}
$name: md;
.col-#{$name}-#{$i}{ @include col($i, $col_num);}
$name: lg;
.col-#{$name}-#{$i}{ @include col($i, $col_num);}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment