// ----------------------------------------- // GRID // Based on ZURB's Foundation 4 // ----------------------------------------- $row-max-width : 1140px !default; $total-columns : 12 !default; $column-gutter : 20px !default; // Calculate percentages for grid @function gridCalc($colNumber, $totalColumns) { @return percentage($colNumber / $totalColumns); } // --------------------------------- // GRID ROW // Create container for the grid // --------------------------------- @mixin grid-row( $nest : false, $collapse : false, $width : $row-max-width, $gutter : $column-gutter, $for-base : false ) { @if $for-base { margin: 0 auto; width: 100%; max-width: $width + $gutter; @if not $responsive { min-width: $width + $gutter; } @include clearfix; } $gutter: em($gutter); @if $nest and $collapse { width: auto; max-width: none; margin: 0; padding-right: 0; padding-left: 0; } @else if $nest { width: auto; max-width: none; margin-right: -($gutter / 2); margin-left: -($gutter / 2); } @else if $collapse { width: 100%; max-width: $width; margin: 0 auto; padding-right: $gutter / 2; padding-left: $gutter / 2; } } @mixin external-call-column( $column : 0, $total : 0, $offset : 0, $parent-offset : 0) { @if $column > 0 { width: gridCalc($column, $total); } @else { width: 100%; } // Offset is only allowed if the column is specified @if $column > 0 and $offset > 0 { margin-#{$default-float}: gridCalc($offset, $total); } // If parent (larger) column has offset, remove it @else if $parent-offset > 0 { margin-#{$default-float}: 0; } } // ------------------------ // GRID COLUMN // Create the grid // ------------------------ @mixin grid-column( $large : 0, $small : 0, // For external call only, small size screen $mini : 0, // For external call only, mini size screen $large-offset : 0, $small-offset : 0, // For external call only $mini-offset : 0, // For external call only $push : 0, $pull : 0, $collapse : false, $center : false, $gutter : $column-gutter, $total : $total-columns, $for-base : false ) { @if $for-base { position: relative; float: $default-float; padding-right: em($gutter) / 2; padding-left: em($gutter) / 2; } // If gutter's value is different from default, it means it is passed as param @if not $gutter == $column-gutter { padding-right: em($gutter) / 2; padding-left: em($gutter) / 2; } // If collapsed, get rid of distance padding @if $collapse { padding-right: 0; padding-left: 0; } // If offset, calculate appropriate margins @if $large-offset > 0 { margin-#{$default-float}: gridCalc($large-offset, $total); } // If a column number is given, calculate width @if $large > 0 { width: gridCalc($large, $total); } // Source Ordering, adds left/right depending on which you use. @if $push > 0 { #{$default-float}: gridCalc($push, $total); #{$default-opposite}: auto; } @if $pull > 0 { #{$default-opposite}: gridCalc($pull, $total); #{$default-float}: auto; } // If centered, get rid of float and add auto margin @if $center { display: block; float: none; margin-right: auto !important; margin-left: auto !important; } // If external call and responsive is true @if $external-call and $responsive { // If small column is specified @if $small > 0 { @include below(small) { @include external-call-column($column:$small, $total:$total, $offset:$small-offset, $parent-offset:$large-offset); } // Mini column is allowed only if Small column is specified @if $mini > 0 { @include below(mini) { @include external-call-column($column:$mini, $total:$total, $offset:$mini-offset, $parent-offset:$small-offset); } } // If mini is not passed, stack the column @else { @include below(mini) { @include external-call-column($column:$mini, $total:$total, $offset:$mini-offset, $parent-offset:$small-offset); } } } // If small is not passed, stack the column @else { @include below(small) { @include external-call-column($column:$small, $total:$total, $offset:$small-offset, $parent-offset:$large-offset); } } } } @if $include-grid { /* --------------- EDGE Grid --------------- */ // Normal row .row { @include grid-row($for-base:true); // Collapsed row &.collapse { @include grid-row($collapse:true); .column, .columns { @include grid-column($collapse:true); } } // Nested-collapsed row .row { @include grid-row($nest:true); &.collapse { @include grid-row($nest:true, $collapse:true); } } } // Normal column .column, .columns { @include grid-column($large:$total-columns, $for-base:true); } @for $i from 1 through $total-columns { .large#{-$i} { @include grid-column($large:$i); } } // Centered column .column.large-centered, .columns.large-centered { @include grid-column($center:true); } // Source Ordering @include above(small) { @for $i from 1 through $total-columns - 1 { .large-offset-#{$i} { @include grid-column($large-offset:$i); } .push#{-$i} { @include grid-column($push:$i); } .pull#{-$i} { @include grid-column($pull:$i); } } } @if $responsive { // Small screen and below @include below(small) { .column, .columns { @include grid-column($large:$total-columns); } @for $i from 1 through $total-columns { .small#{-$i} { @include grid-column($large:$i); } } @for $i from 0 through $total-columns - 2 { .small-offset-#{$i} { @include grid-column($large-offset:$i); } } .column.small-centered, .columns.small-centered { @include grid-column($center:true); } } } // responsive } // $include-grid