Last active
December 21, 2015 06:08
-
-
Save seajones/6261618 to your computer and use it in GitHub Desktop.
Easy conversion of px to ems
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
| // First, set a base size in the document - do this on HTML, or BODY, I tend towards HTML | |
| html { | |
| font-size: $base-font; | |
| } | |
| // Generally somewhere else (my SCSS is more structured than this, put this function (somewhere before you're going to use it) | |
| @function ems($p, $b: $base-font) { | |
| @return ($p / $b) * 1em; /* Because SASS/SCSS allows you to mix units, you can calculate this proportion in pixels, and then just multiply by 1em to get the o/p in ems */ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment