Created
March 26, 2013 15:43
-
-
Save paulmsmith/5246420 to your computer and use it in GitHub Desktop.
sass-ie-rem-mixin
This file contains 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
// rem font and line-height mixin. Accepts a font-size, line-height and ratio numeric (without unit, "14" - not "14px") | |
// the line height defaults to the passed font-size and the ratio defaults to 1.5 (150%) | |
// as the body is 62.5% we can use base10 to determin the REM value and just append px for the pixel fallback | |
@mixin font-size($size: 14, $line: $size, $ratio: 1.5){ | |
// size variables | |
$remValueFontSize: ($size / 10) + rem; | |
$remValueLine: ($line / 10) * $ratio + rem; | |
$pxValueFontSize: floor($size) + px; | |
$pxValueLine: floor($size * $ratio) + px; | |
// if output to correct css file | |
@if $old-ie == true { | |
@include old-ie { | |
// fallback pixel sizes | |
font-size: $pxValueFontSize; | |
line-height: $pxValueLine; | |
} | |
} @else { | |
font-size: $remValueFontSize; | |
line-height: $remValueLine; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment