Skip to content

Instantly share code, notes, and snippets.

@bcinarli
Created June 7, 2014 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcinarli/f3336692d0dd45ab0dfe to your computer and use it in GitHub Desktop.
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
/* @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