Skip to content

Instantly share code, notes, and snippets.

@philbirnie
Last active December 14, 2015 21:49
Show Gist options
  • Save philbirnie/5154295 to your computer and use it in GitHub Desktop.
Save philbirnie/5154295 to your computer and use it in GitHub Desktop.
Mixin for REM font-size
/** 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