Created
January 2, 2014 16:42
-
-
Save rwaymouth/8222065 to your computer and use it in GitHub Desktop.
Responsive Grid generator
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
$gutter: 1em; | |
$gutter-mod: 4; // Simple way to change gutter proportions at smaller screen sizes. | |
$grid-num: 12; | |
$break: 30em; | |
%cf { | |
&:after { | |
content:""; | |
display:table; | |
clear:both; | |
} | |
} | |
%group { | |
@extend %cf; | |
padding: $gutter/2; | |
@media (min-width: $break) { | |
padding: $gutter/(2*$gutter-mod); | |
} | |
} | |
%grid-base { | |
float: left; | |
margin: $gutter/(2*$gutter-mod); | |
@media (min-width: $break) { | |
width: calc(100% - (#{$gutter}/#{$gutter-mod})); | |
margin: $gutter/2; | |
} | |
} | |
@function build ($num) { | |
$grid: percentage($num/$grid-num); | |
@return calc(#{$grid} - (#{$gutter}/#{$gutter-mod})); | |
} | |
@function build-large ($num) { | |
$grid: percentage($num/$grid-num); | |
@return calc(#{$grid} - #{$gutter}); | |
} | |
@mixin grid($m: $grid-num, $d:$grid-num ) { | |
width: build($m); | |
@extend %grid-base; | |
@media (min-width: $break) { | |
width: build-large($d); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment