Created
July 18, 2011 01:04
-
-
Save makenosound/1088326 to your computer and use it in GitHub Desktop.
SASS plugin for Andy Taylor's 1140 grid
This file contains 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
$eleven40-grid-width: 4.85% !default; // The width of a column | |
$eleven40-grid-margin: 3.8% !default; // The amount of margin between columns | |
@mixin eleven40-container { | |
padding-left: 20px; | |
padding-right: 20px; | |
} | |
@mixin eleven40-row { | |
margin: 0 auto; | |
max-width: 1140px; | |
overflow: hidden; | |
width: 100%; | |
} | |
/* | |
Main mixin, set the width of `$columns` columns | |
Can be changed based on the width of the parent column. I.e., to create a 4-column | |
<div> inside a 10-column <div> you would do the following: | |
@include eleven40-column(4, false, 10); | |
*/ | |
@mixin eleven40-column($columns, $last: false, $parent: 12) { | |
display: inline; | |
float: left; | |
width: eleven40-span($columns, $parent); | |
@if $last { | |
margin-right: 0; } | |
@else { | |
margin-right: eleven40-margin($eleven40-grid-margin, $parent); } | |
} | |
@mixin eleven40-push($columns, $parent: 12) { | |
margin-left: eleven40-push-margin($columns, $parent); | |
} | |
// Function to calculate width in context | |
@function eleven40-span($columns, $parent: 12) { | |
@return ($eleven40-grid-width * $columns + $eleven40-grid-margin * ($columns - 1)) / ($eleven40-grid-width * $parent + $eleven40-grid-margin * ($parent - 1)) * 100%; | |
} | |
// Function to calculate margins in context | |
@function eleven40-margin($margin, $parent: 12) { | |
@return $margin / eleven40-span($parent) * 100%; | |
} | |
// Function to calculate push in context | |
@function eleven40-push-margin($columns, $parent: 12) { | |
@return ($eleven40-grid-width * $columns + $eleven40-grid-margin * $columns) / ($eleven40-grid-width * $parent + $eleven40-grid-margin * ($parent - 1)) * 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment