Skip to content

Instantly share code, notes, and snippets.

@yvesvanbroekhoven
Created February 19, 2012 09:23
Show Gist options
  • Select an option

  • Save yvesvanbroekhoven/1862723 to your computer and use it in GitHub Desktop.

Select an option

Save yvesvanbroekhoven/1862723 to your computer and use it in GitHub Desktop.
Sass semantic grid approach
// Defaults which you can freely override
$column-width: 60px;
$gutter-width: 20px;
$columns: 12;
// Utility function — you should never need to modify this
@function gridsystem-width($columns:$columns) {
@return ($column-width * $columns) + ($gutter-width * $columns);
}
@mixin row($columns) {
@include clearfix;
display: block;
width: gridsystem-width($columns);
margin: 0 (($gutter-width * .5) * -1)
}
@mixin column($x) {
display: inline;
float: left;
width: (($gutter-width + $column-width) * $x) - $gutter-width;
margin: 0 ($gutter-width / 2);
}
@mixin offset($offset: 1) {
margin-left: $offset * ($column-width + $gutter-width) + ($gutter-width / 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment