Skip to content

Instantly share code, notes, and snippets.

@crswll
Created August 5, 2014 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crswll/c36e5f381bea8075d55e to your computer and use it in GitHub Desktop.
Save crswll/c36e5f381bea8075d55e to your computer and use it in GitHub Desktop.
@mixin mega-blocks ($width, $columns, $selector) {
$index: 1;
$number-of-columns: length($columns);
width: ($width * $number-of-columns) + 0px;
position: relative;
#{$selector} {
position: absolute;
width: $width + 0px;
@for $i from 0 through ( $number-of-columns - 1 ) {
$rows: nth($columns, $i + 1);
$height: 100 / $rows;
@for $j from 0 through ( $rows - 1 ) {
&:nth-child(#{$index}) {
top: ( $height * $j ) + 0%;
left: ( $width * $i ) + 0px;
height: $height + 0%;
}
$index: $index + 1;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment