// ----------------------------------------- // GRID // Based heavily on ZURB's Foundation // ----------------------------------------- $column-distance : 30px !default; $row-max-width : $content-width !default; $total-columns : 12 !default; // Calculate percentages for grid @function gridCalc($colNumber, $totalColumns:$total-columns) { @return percentage($colNumber / $totalColumns); } // For creating container, nested, and collapsed rows. @mixin grid-row( $behavior : false, $for-base : false, $max-width : $row-max-width, $distance : $column-distance ) { $max-width : em($max-width) + em($distance); // to make up for the padding // prevent duplicate for base CSS class @if $for-base == false { @include clearfix; } // use @include grid-row(nest); to include a nested row @if $behavior == nest { width : auto; max-width : none; margin-#{$default-float} : -($distance / 2); margin-#{$default-opposite} : -($distance / 2); } // use @include grid-row(collapse); to collapse a container row margins @else if $behavior == collapse { width : 100%; max-width : $max-width; margin : 0; } // use @include grid-row(nest-collapse); to collapse outer margins on a nested row @else if $behavior == nest-collapse { width : auto; max-width : none; margin : 0; } // use @include grid-row; to use a container row @else { width : 100%; max-width : $max-width; margin : 0 auto; } } // For creating columns - @include these inside a media query to control small vs. large grid layouts @mixin grid-column( $columns : false, $last-column : false, $center : false, $offset : false, $push : false, $pull : false, $collapse : false, $float : true, $for-base : false, $distance : $column-distance, $total-columns : $total-columns, $external : $external-call, // Mixin used from external file $small : false // For usage by external file, apply CSS for small-grid ) { @if $for-base == false { position: relative; } // If collapsed, get rid of distance padding @if $collapse { padding-left : 0; padding-right : 0; } // Distance padding whenever a column isn't set to collapse // (use $collapse:null to do nothing) @else if $collapse == false { padding-left : $distance / 2; padding-right : $distance / 2; } // If a column number is given, calculate width @if $columns { width : gridCalc($columns, $total-columns); // If last column, float naturally instead of to the right @if $last-column { float: $default-opposite; } } // If offset, calculate appropriate margins @if $offset { margin-#{$default-float}: gridCalc($offset, $total-columns); } // Source Ordering, adds left/right depending on which you use. @if $push { #{$default-float} : gridCalc($push, $total-columns); #{$default-opposite} : auto; } @if $pull { #{$default-opposite} : gridCalc($pull, $total-columns); #{$default-float} : auto; } // If centered, get rid of float and add appropriate margins @if $center { margin-#{$default-float} : auto !important; margin-#{$default-opposite} : auto !important; float : none !important; } @if $float { @if $float == left or $float == true { float: $default-float; } @else if $float == right { float: $default-opposite; } @else { float: none; } } // If used from external file and size is not small @if $external { @if $small == false { @include small { width : 100%; } } } } @if $include-grid { /* --------------- EDGE Grid --------------- */ body { &.not-responsive { min-width : $row-max-width; } &.only-responsive-below-small { min-width : $row-max-width; @include small { min-width : 0; } } } .row { @include grid-row; // Collapsed row &.collapse { .column, .columns { @include grid-column($collapse:true, $for-base:false); } } // Nested-collapsed row .row { @include grid-row($behavior:nest); &.collapse { @include grid-row($behavior:nest-collapse); } } } // Normal column .column, .columns { @include grid-column($columns:$total-columns); } @for $i from 1 through $total-columns { .large#{-$i} { @include grid-column($columns:$i, $collapse:null, $float:false, $for-base:true); } } @for $i from 0 through $total-columns - 1 { .row .large-offset-#{$i} { @include grid-column($offset:$i, $collapse:null, $float:false, $for-base:true); } } // Centered column .column.large-centered, .columns.large-centered { @include grid-column($center:true, $collapse:null, $float:false); } @include medium-up { @for $i from 1 through $total-columns - 1 { .push#{-$i} { @include grid-column($push:$i, $collapse:null, $float:false, $for-base:true); } .pull#{-$i} { @include grid-column($pull:$i, $collapse:null, $float:false, $for-base:true); } } } // Small screen and below @include small { .column, .columns { @include grid-column($columns:$total-columns); } @for $i from 1 through $total-columns { .small#{-$i} { @include grid-column($columns:$i, $collapse:null, $float:false, $for-base:true); } } @for $i from 0 through $total-columns - 2 { .small-offset-#{$i} { @include grid-column($offset:$i, $collapse:null, $float:false, $for-base:true); } } .column.small-centered, .columns.small-centered { @include grid-column($center:true, $collapse:null, $float:false); } } } // $include-grid