Automatically create a EM valued font style with automatic line-height
$basefontsize: 16px;
@function calculateEm($size) {
$remSize: $size / $basefontsize;
@return $emSize * 1em;
}
@function lineheight($size) {
$stripped: $size / ($size * 1 + 1);
$lineHeight: ($stripped) * 1.6;
@return ($lineHeight) * 1em;
}
@mixin typeheight($size) {
font-size: $size;
font-size: calculateEm($size);
line-height: lineheight($size);
}
body {
@include typeheight($basefontsize);
}
h1 {
@include typeheight(36px);
}
body {
font-size: 16px;
font-size: 1em;
line-height: 1.50588em;
}
h1 {
font-size: 36px;
font-size: 2.25em;
line-height: 1.55676em;
}