Skip to content

Instantly share code, notes, and snippets.

@pixelbacon
Last active August 29, 2015 14:06
Show Gist options
  • Save pixelbacon/7bad836c843b34632975 to your computer and use it in GitHub Desktop.
Save pixelbacon/7bad836c843b34632975 to your computer and use it in GitHub Desktop.
Simple columns in Sass
@mixin set-columns($numCols, $margin:0, $padding-sides:0) {
$afterPadding: 100% - (($numCols - 1) * $margin);
float: left;
width: $afterPadding/$numCols;
margin-right: $margin;
padding-left: $padding-sides/2;
padding-right: $padding-sides/2;
&:nth-of-type(#{$numCols}n + #{$numCols}) {
margin-right: 0;
}
&:nth-of-type(#{$numCols}n - #{($numCols * 2) - 1}) {
clear: both;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment