Created
August 20, 2014 12:11
-
-
Save HelloTiago/f47bc50cce9a0a4b07fb to your computer and use it in GitHub Desktop.
Simple SCSS function to convert pixels to rems.
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
/** | |
* | |
* Convert pixels to rems | |
* eg. for a relational value of 12px write rem(12) | |
* $base is usually the font-size on your body element. | |
* And it can be defined outside the function, in a variables.scss file for example. | |
* | |
**/ | |
@function rem($pxval) { | |
@if not unitless($pxval) { | |
$pxval: strip-units($pxval); | |
} | |
$base: 16px; | |
@if not unitless($base) { | |
$base: strip-units($base); | |
} | |
@return ($pxval / $base) * 1rem; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment