Skip to content

Instantly share code, notes, and snippets.

@kiyeon
Last active March 30, 2017 06:56
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 kiyeon/0ed34fc57880d3ec20fb020817b89bb8 to your computer and use it in GitHub Desktop.
Save kiyeon/0ed34fc57880d3ec20fb020817b89bb8 to your computer and use it in GitHub Desktop.
kiyeon's sass
@function _px2($px, $unit) {
$BROWSER_FONTSIZE: 16px;
@if (unitless($px)) { $px: $px * 1px; }
@if (unitless($BROWSER_FONTSIZE)) { $BROWSER_FONTSIZE: $BROWSER_FONTSIZE * 1px; }
@return $px / $BROWSER_FONTSIZE * $unit;
}
@function rem($px) {
@return _px2($px, 1rem);
}
@function em($px) {
@return _px2($px, 1em);
}
@kiyeon
Copy link
Author

kiyeon commented Mar 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment