Skip to content

Instantly share code, notes, and snippets.

@plasticine
Created August 15, 2011 01:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plasticine/1145584 to your computer and use it in GitHub Desktop.
Save plasticine/1145584 to your computer and use it in GitHub Desktop.
Generate a grid.
$grid_col_names:(
'one', 'two', 'three', 'four', 'five', 'six',
'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'
);
@function col($count:1){ @return (($grid_col_width + $grid_gutter) * $count) - $grid_gutter; }
@mixin pre_col($count:1){ margin-left: col($count); }
@mixin post_col($count:1){ margin-right: col($count); }
@mixin make_grid_classes{
@for $index from 1 through $grid_num_cols {
.grid-#{nth($grid_col_names, $index)} {
width: col($index);
float:left;
margin-right:$grid_gutter;
outline:1px solid #eee;
}
.grid-pre-#{nth($grid_col_names, $index)} { @include pre_col($index); }
.grid-post-#{nth($grid_col_names, $index)} { @include post_col($index); }
}
.grid-last{ margin-right:0; }
}
@mixin grid{
margin:0 auto;
width:col($grid_num_cols);
@include make_grid_classes;
}
.grid{ @include grid; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment