Skip to content

Instantly share code, notes, and snippets.

@gavinmcfarland
Created July 19, 2013 16:55
Show Gist options
  • Select an option

  • Save gavinmcfarland/6040673 to your computer and use it in GitHub Desktop.

Select an option

Save gavinmcfarland/6040673 to your computer and use it in GitHub Desktop.
A mixin that works out all the percentages for your grid. Just specify how many columns it's has and how big you want the gutter (in percentages) to be.
@mixin grid($columns, $gutter) {
@if $columns > 1 {
$fWidth: (1/$columns * 100%) - ($gutter * ($columns - 1) / $columns);
@include clearfix;
> li {
width: #{$fWidth};
box-sizing: border-box;
float: left;
margin-left: $gutter;
&:nth-child(#{$columns}n + 1) {
margin-left: 0;
clear: both;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment