Created
June 7, 2014 18:02
-
-
Save bcinarli/f3336692d0dd45ab0dfe to your computer and use it in GitHub Desktop.
Rem to PX and PX to Rem conversions according to defined $base-font-size
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 characters
/* @author Bilal Cinarli */ | |
/** ------------------------------------------- | |
Text Related Functions | |
------------------------------------------- **/ | |
/** | |
* Rem to PX | |
*/ | |
@function rem-to-px($font-size) { | |
$u: unit($font-size); | |
@if($u == 'px'){ | |
@return $font-size; | |
} | |
$unitless: remove-unit($font-size); | |
@return $unitless * $base-font-size; | |
} | |
/** | |
* REM converter | |
*/ | |
@function rem($font-size) { | |
$u: unit($font-size); | |
// rem calculations | |
@if ($u == 'rem'){ | |
@return $font-size; | |
} @else { | |
$convert: $font-size/$base-font-size; | |
@return #{$convert}rem; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment