Created
June 19, 2012 03:34
-
-
Save scottkellum/2952148 to your computer and use it in GitHub Desktop.
Compound grid logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compound($c1: 1, $c2: 1, $c3: 1, $c4: 1, $c5: 1, $c6: 1) | |
$common-multiple: ($c1 * $c2 * $c3 * $c4 * $c5 * $c6) | |
$compound-grid: () | |
$compound-counter: 1 | |
@for $i from 1 through $common-multiple | |
$add-col: false | |
@if $c1 !=1 | |
@if $i / $c1 == round($i / $c1) | |
$add-col: true | |
@if $c2 !=1 | |
@if $i / $c2 == round($i / $c2) | |
$add-col: true | |
@if $c3 !=1 | |
@if $i / $c3 == round($i / $c3) | |
$add-col: true | |
@if $c4 !=1 | |
@if $i / $c4 == round($i / $c4) | |
$add-col: true | |
@if $c5 !=1 | |
@if $i / $c5 == round($i / $c5) | |
$add-col: true | |
@if $c6 !=1 | |
@if $i / $c6 == round($i / $c6) | |
$add-col: true | |
@if $add-col | |
$compound-grid: join($compound-grid, $compound-counter) | |
$compound-counter: 1 | |
@else | |
$compound-counter: $compound-counter + 1 | |
@return $compound-grid |
Already merged with the singularity branch. So @import the _grid file in that branch, set $columns: compound(6, 4)
or whatever grids you want to compound (up to 6 grids can be compounded).
Now use width: grid-span($span, $start-location)
or how ever many columns you want where ever you want it to start.
You can also use the mixin +span-grid($span, $start-location)
. It has a built in counter if you are going from left to right so you don’t need to use the location at all if you start on the first column and end at the last column.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very awesome! After seeing the Gerstner I was going to ask if anyone had thought of doing compound grids....seems you beat me to it :)
How do you call those in your Sass include?