Last active
December 14, 2015 21:49
-
-
Save philbirnie/5154295 to your computer and use it in GitHub Desktop.
Mixin for REM font-size
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
/** Font Size is in REMs,margins are mutiples of the base value | |
Line height is automatically set based upon the font size */ | |
.font-size(@sizeValue, @margin-bottom: 0, @margin-top: 0) | |
{ | |
@base: 2.2; | |
@remValue: @sizeValue; | |
@pxValue: (@sizeValue * 10); | |
@lineHeightRem: ceil(@sizeValue / @base)*@base; | |
@lineHeightPx: (@lineHeightRem * 10); | |
@marginTopRem: (@margin-top * @base); | |
@marginTopPx: (@marginTopRem * 10); | |
@marginBottomRem: (@margin-bottom * @base); | |
@marginBottomPx: (@marginBottomRem * 10); | |
font-size: ~"@{pxValue}px"; | |
font-size: ~"@{remValue}rem"; | |
line-height: ~"@{lineHeightPx}px"; | |
line-height: ~"@{lineHeightRem}rem"; | |
margin-top: ~"@{marginTopPx}px"; | |
margin-top: ~"@{marginTopRem}rem"; | |
margin-bottom: ~"@{marginBottomPx}px"; | |
margin-bottom: ~"@{marginBottomRem}rem"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment