Skip to content

Instantly share code, notes, and snippets.

@anareyna
Created June 17, 2014 22:06
Show Gist options
  • Save anareyna/05a005dede5fef2a821c to your computer and use it in GitHub Desktop.
Save anareyna/05a005dede5fef2a821c to your computer and use it in GitHub Desktop.
Mixins to convert "em, rem and px" units with stylus
$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