Created
January 23, 2014 04:18
-
-
Save joshkennedy/8572756 to your computer and use it in GitHub Desktop.
Basic Sass grid
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
@function calculateWidth($cols, $margin) { | |
@return ((100% - (($cols - 1)*$margin)) / $cols) | |
} | |
@mixin one-whole { | |
width: 100%; | |
} | |
@mixin one-half { | |
$margin: 2; | |
width: calculateWidth(2, $margin); | |
margin-right: $margin * 1%; | |
&:nth-child(2n) { | |
margin-right: 0; | |
} | |
} | |
@mixin one-third { | |
$margin: 4; | |
width: calculateWidth(3, $margin); | |
margin-right: $margin * 1%; | |
&:nth-child(3n) { | |
margin-right: 0; | |
} | |
} | |
@mixin one-quarter { | |
$margin: 2; | |
width: calculateWidth(4, $margin); | |
margin-right: $margin * 1%; | |
&:nth-child(4n) { | |
margin-right: 0; | |
} | |
} | |
@mixin two-thirds { | |
$margin: 4; | |
$widthOfOneThird: calculateWidth(3, $margin); | |
width: ($widthOfOneThird * 2) + $margin; | |
margin-right: $margin * 1%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment