Created
June 2, 2014 11:31
-
-
Save danielguillan/46d007124819a90a69d0 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.3.7) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
$use-fractions: false !default; | |
$numbers: (1 one whole, 2 two half, 3 three third, 4 four quater, 5 five fifth, 6 six sixth, 7 seven seventh, 8 eight eighth, 9 nine ninth, 10 ten tenth, 11 eleven eleventh, 12 twleve twelfth, 13 thirteen thirteenth, 14 fourteen fourteenth, 15 fifteen fifteenth, 16 sixteen sixteenth); | |
@mixin widths($prefix: '', $widths...) { | |
// Generate all numbers? | |
@if (length($widths) == 0) { | |
$widths: (); | |
@each $n in $numbers { | |
$widths: append($widths, nth($n, 1), comma); | |
} | |
} | |
@each $number1 in $numbers { | |
@each $number2 in $numbers { | |
// Store number values | |
$a: nth($number1, 1); | |
$b: nth($number2, 1); | |
@if (not not index($widths, $b)) { | |
// Only generate classes for positive fractions or one whole | |
@if ($b >= $a and $a < $b or ($a == 1 and $b == 1)) { | |
// Calculate width | |
$width: 100% / $b / $a; | |
@if ($use-fractions) { | |
// Fractions class-names (e.g. 1/1, 2/6, …) | |
[class~="#{$prefix}#{$a}/#{$b}"] { | |
width: $width; | |
} | |
} @else { | |
// Base class names (e.g. .one-whole, .two-sixths, …) | |
.#{$prefix}#{nth($number1, 2)}-#{nth($number2, 3)}#{if($b > 1 and $a != 1, 's', '')} { | |
width: $width; | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
// -------------------------------------------------------------------------------- | |
// Usage | |
// -------------------------------------------------------------------------------- | |
// Generate all widths | |
@include widths(); | |
// Generate some widths | |
// @include widths('', 1, 2, 3, 4); | |
// Media query specific widths using a prefix | |
// @media screen and (max-width: 320px) { | |
// @include widths('small-'); | |
// } |
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
.one-whole { | |
width: 100%; | |
} | |
.one-half { | |
width: 50%; | |
} | |
.one-third { | |
width: 33.33333%; | |
} | |
.one-quater { | |
width: 25%; | |
} | |
.one-fifth { | |
width: 20%; | |
} | |
.one-sixth { | |
width: 16.66667%; | |
} | |
.one-seventh { | |
width: 14.28571%; | |
} | |
.one-eighth { | |
width: 12.5%; | |
} | |
.one-ninth { | |
width: 11.11111%; | |
} | |
.one-tenth { | |
width: 10%; | |
} | |
.one-eleventh { | |
width: 9.09091%; | |
} | |
.one-twelfth { | |
width: 8.33333%; | |
} | |
.one-thirteenth { | |
width: 7.69231%; | |
} | |
.one-fourteenth { | |
width: 7.14286%; | |
} | |
.one-fifteenth { | |
width: 6.66667%; | |
} | |
.one-sixteenth { | |
width: 6.25%; | |
} | |
.two-thirds { | |
width: 16.66667%; | |
} | |
.two-quaters { | |
width: 12.5%; | |
} | |
.two-fifths { | |
width: 10%; | |
} | |
.two-sixths { | |
width: 8.33333%; | |
} | |
.two-sevenths { | |
width: 7.14286%; | |
} | |
.two-eighths { | |
width: 6.25%; | |
} | |
.two-ninths { | |
width: 5.55556%; | |
} | |
.two-tenths { | |
width: 5%; | |
} | |
.two-elevenths { | |
width: 4.54545%; | |
} | |
.two-twelfths { | |
width: 4.16667%; | |
} | |
.two-thirteenths { | |
width: 3.84615%; | |
} | |
.two-fourteenths { | |
width: 3.57143%; | |
} | |
.two-fifteenths { | |
width: 3.33333%; | |
} | |
.two-sixteenths { | |
width: 3.125%; | |
} | |
.three-quaters { | |
width: 8.33333%; | |
} | |
.three-fifths { | |
width: 6.66667%; | |
} | |
.three-sixths { | |
width: 5.55556%; | |
} | |
.three-sevenths { | |
width: 4.7619%; | |
} | |
.three-eighths { | |
width: 4.16667%; | |
} | |
.three-ninths { | |
width: 3.7037%; | |
} | |
.three-tenths { | |
width: 3.33333%; | |
} | |
.three-elevenths { | |
width: 3.0303%; | |
} | |
.three-twelfths { | |
width: 2.77778%; | |
} | |
.three-thirteenths { | |
width: 2.5641%; | |
} | |
.three-fourteenths { | |
width: 2.38095%; | |
} | |
.three-fifteenths { | |
width: 2.22222%; | |
} | |
.three-sixteenths { | |
width: 2.08333%; | |
} | |
.four-fifths { | |
width: 5%; | |
} | |
.four-sixths { | |
width: 4.16667%; | |
} | |
.four-sevenths { | |
width: 3.57143%; | |
} | |
.four-eighths { | |
width: 3.125%; | |
} | |
.four-ninths { | |
width: 2.77778%; | |
} | |
.four-tenths { | |
width: 2.5%; | |
} | |
.four-elevenths { | |
width: 2.27273%; | |
} | |
.four-twelfths { | |
width: 2.08333%; | |
} | |
.four-thirteenths { | |
width: 1.92308%; | |
} | |
.four-fourteenths { | |
width: 1.78571%; | |
} | |
.four-fifteenths { | |
width: 1.66667%; | |
} | |
.four-sixteenths { | |
width: 1.5625%; | |
} | |
.five-sixths { | |
width: 3.33333%; | |
} | |
.five-sevenths { | |
width: 2.85714%; | |
} | |
.five-eighths { | |
width: 2.5%; | |
} | |
.five-ninths { | |
width: 2.22222%; | |
} | |
.five-tenths { | |
width: 2%; | |
} | |
.five-elevenths { | |
width: 1.81818%; | |
} | |
.five-twelfths { | |
width: 1.66667%; | |
} | |
.five-thirteenths { | |
width: 1.53846%; | |
} | |
.five-fourteenths { | |
width: 1.42857%; | |
} | |
.five-fifteenths { | |
width: 1.33333%; | |
} | |
.five-sixteenths { | |
width: 1.25%; | |
} | |
.six-sevenths { | |
width: 2.38095%; | |
} | |
.six-eighths { | |
width: 2.08333%; | |
} | |
.six-ninths { | |
width: 1.85185%; | |
} | |
.six-tenths { | |
width: 1.66667%; | |
} | |
.six-elevenths { | |
width: 1.51515%; | |
} | |
.six-twelfths { | |
width: 1.38889%; | |
} | |
.six-thirteenths { | |
width: 1.28205%; | |
} | |
.six-fourteenths { | |
width: 1.19048%; | |
} | |
.six-fifteenths { | |
width: 1.11111%; | |
} | |
.six-sixteenths { | |
width: 1.04167%; | |
} | |
.seven-eighths { | |
width: 1.78571%; | |
} | |
.seven-ninths { | |
width: 1.5873%; | |
} | |
.seven-tenths { | |
width: 1.42857%; | |
} | |
.seven-elevenths { | |
width: 1.2987%; | |
} | |
.seven-twelfths { | |
width: 1.19048%; | |
} | |
.seven-thirteenths { | |
width: 1.0989%; | |
} | |
.seven-fourteenths { | |
width: 1.02041%; | |
} | |
.seven-fifteenths { | |
width: 0.95238%; | |
} | |
.seven-sixteenths { | |
width: 0.89286%; | |
} | |
.eight-ninths { | |
width: 1.38889%; | |
} | |
.eight-tenths { | |
width: 1.25%; | |
} | |
.eight-elevenths { | |
width: 1.13636%; | |
} | |
.eight-twelfths { | |
width: 1.04167%; | |
} | |
.eight-thirteenths { | |
width: 0.96154%; | |
} | |
.eight-fourteenths { | |
width: 0.89286%; | |
} | |
.eight-fifteenths { | |
width: 0.83333%; | |
} | |
.eight-sixteenths { | |
width: 0.78125%; | |
} | |
.nine-tenths { | |
width: 1.11111%; | |
} | |
.nine-elevenths { | |
width: 1.0101%; | |
} | |
.nine-twelfths { | |
width: 0.92593%; | |
} | |
.nine-thirteenths { | |
width: 0.8547%; | |
} | |
.nine-fourteenths { | |
width: 0.79365%; | |
} | |
.nine-fifteenths { | |
width: 0.74074%; | |
} | |
.nine-sixteenths { | |
width: 0.69444%; | |
} | |
.ten-elevenths { | |
width: 0.90909%; | |
} | |
.ten-twelfths { | |
width: 0.83333%; | |
} | |
.ten-thirteenths { | |
width: 0.76923%; | |
} | |
.ten-fourteenths { | |
width: 0.71429%; | |
} | |
.ten-fifteenths { | |
width: 0.66667%; | |
} | |
.ten-sixteenths { | |
width: 0.625%; | |
} | |
.eleven-twelfths { | |
width: 0.75758%; | |
} | |
.eleven-thirteenths { | |
width: 0.6993%; | |
} | |
.eleven-fourteenths { | |
width: 0.64935%; | |
} | |
.eleven-fifteenths { | |
width: 0.60606%; | |
} | |
.eleven-sixteenths { | |
width: 0.56818%; | |
} | |
.twleve-thirteenths { | |
width: 0.64103%; | |
} | |
.twleve-fourteenths { | |
width: 0.59524%; | |
} | |
.twleve-fifteenths { | |
width: 0.55556%; | |
} | |
.twleve-sixteenths { | |
width: 0.52083%; | |
} | |
.thirteen-fourteenths { | |
width: 0.54945%; | |
} | |
.thirteen-fifteenths { | |
width: 0.51282%; | |
} | |
.thirteen-sixteenths { | |
width: 0.48077%; | |
} | |
.fourteen-fifteenths { | |
width: 0.47619%; | |
} | |
.fourteen-sixteenths { | |
width: 0.44643%; | |
} | |
.fifteen-sixteenths { | |
width: 0.41667%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment