Created
June 17, 2014 22:06
-
-
Save anareyna/05a005dede5fef2a821c to your computer and use it in GitHub Desktop.
Mixins to convert "em, rem and px" units with stylus
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
$basefont = 14px | |
em(size, parentFontSize = 0) | |
if parentFontSize == 0 | |
font-size round(( size / $basefont )em , 3) | |
else | |
font-size round(( size / parentFontSize )em , 3) | |
rem(size) | |
font-size ( size )px | |
font-size round(( size / $basefont )rem , 3) | |
px(size) | |
font-size ( size * $basefont )px | |
// Example usage | |
// em(12px) | |
// em(20px, 12px) | |
// px(2.5em) | |
// rem(18px) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment