Created
July 18, 2015 18:08
-
-
Save jdeagle/0e52565a6279ba107b6d to your computer and use it in GitHub Desktop.
Revisions
-
jdeagle created this gist
Jul 18, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ // ---- // libsass (v3.2.5) // ---- @function get-px-from-vw($vw, $contextWidth) { @return (($contextWidth / 100) * $vw) + px; } @function strip-units($number) { @if type-of($number) == "number" and not unitless($number) { @return $number / ($number * 0 + 1); } @return $number; } @mixin font-size($sizeValue: 1.6, $line: $sizeValue + .5, $contextWidth:0) { // // examples // set as REM // @include font-size(16.4, 14.5); // // set as VW // @include font-size(6.45vw, 8vw); // @if type-of($sizeValue) == "number" and unitless($sizeValue) { font-size: ($sizeValue * 10) + px; line-height: ($line * 10) + px; font-size: $sizeValue + rem; line-height: $line + rem; } @else { @if $contextWidth > 0 and unit($sizeValue) == vw { font-size: get-px-from-vw(strip-units($sizeValue), strip-units($contextWidth)); line-height: get-px-from-vw(strip-units($line), strip-units($contextWidth)); } font-size: $sizeValue; line-height: ($line); } } .foo { @include font-size(6.25vw, 7vw, 320); } .bar { @include font-size(6.25px, 7vw, 320); } .baz { @include font-size(6.25vw, 7vw); } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ .foo { font-size: 20px; line-height: 22.4px; font-size: 6.25vw; line-height: 7vw; } .bar { font-size: 6.25px; line-height: 7vw; } .baz { font-size: 6.25vw; line-height: 7vw; }