Last active
August 29, 2015 13:57
-
-
Save steverydz/9453035 to your computer and use it in GitHub Desktop.
An example grid system using Sass mixins.
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
// Config | |
$container-width: 96% !default; | |
$container-max-width: 1200px !default; | |
$grid-base-outer-width: 940 !default; | |
$grid-base-col-width: 60 !default; | |
$grid-base-gutter-width: 20 !default; | |
$grid-cols: 12 !default; | |
// Clearfix | |
@mixin clearfix { | |
&:before, | |
&:after { | |
content: " "; | |
display: table; | |
} | |
&:after { | |
clear: both; | |
} | |
} | |
// Container | |
@mixin container { | |
@include clearfix; | |
width: $container-width; | |
max-width: $container-max-width; | |
margin: 0 auto; | |
} | |
// Row | |
@mixin row { | |
@include clearfix; | |
} | |
// Grid columns | |
$grid-col-width: percentage($grid-base-col-width / $grid-base-outer-width); | |
$grid-gutter-width: percentage($grid-base-gutter-width / $grid-base-outer-width); | |
@mixin span-columns($cols) { | |
float: left; | |
width: ($grid-col-width + $grid-gutter-width) * $cols - $grid-gutter-width; | |
margin-right: $grid-gutter-width; | |
&:last-child { | |
margin-right: 0; | |
} | |
} | |
// Clears last column of row | |
@mixin omega($nth) { | |
&:nth-child(#{$nth}) { | |
margin-right: 0; | |
} | |
} | |
// Reset row | |
@mixin omega-reset($nth) { | |
&:nth-child(#{nth}) { | |
margin-right: $grid-gutter-width; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment