Skip to content

Instantly share code, notes, and snippets.

@jackabox
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save jackabox/6f5b65b1e52095972e19 to your computer and use it in GitHub Desktop.

Select an option

Save jackabox/6f5b65b1e52095972e19 to your computer and use it in GitHub Desktop.
Generating a grid in sass.
// Your columns are at a weird width here - Use the gutter on the row as well.
$width: 1244px;
$columns: 12;
$gutter: 16px;
.row {
width: 100%;
max-width: $width;
box-sizing: border-box;
padding: 0 $gutter;
&:after {
content: "";
display: table;
clear: both;
}
}
.column,
.columns {
float: left;
min-height: 1px;
margin-left: $gutter;
&:first-child{
margin-left: 0;
}
}
@function columns($i){
@return ( ($width/$columns) * $i ) / $width * 100;
}
@for $i from 1 through $columns{
.col-#{$i}.column {
width: calc( #{columns($i)}% - #{$gutter});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment