Skip to content

Instantly share code, notes, and snippets.

@magicspon
Last active August 29, 2015 14:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicspon/88a4ad68c0ed811877f2 to your computer and use it in GitHub Desktop.
Save magicspon/88a4ad68c0ed811877f2 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
$base-font-size: 16px;
$base-line-height: 24px;
@function computeLineHeight($font-size, $computed) {
$fs: strip-units($font-size);
@return $computed / $fs;
}
@function strip-units($value) {
@return $value / ($value * 0 + 1);
}
@mixin font-size($font-size, $line-height: true) {
font-size: $font-size;
font-size: ($font-size / $base-font-size) * 1rem;
@if $line-height == true {
line-height: ceil($font-size / $base-line-height) * ($base-line-height / $font-size);
}
@elseif $line-height != false {
@if type-of($line-height) == number {
@if unitless($line-height) {
line-height: computeLineHeight($font-size, $line-height);
}
}
// @else { @warn "the line-height value should be unitless" }
// @warn not supported in libsass
}
}
.default-vertical-rhythm {
@include font-size(62px);
}
.explict-line-height {
@include font-size(62px, 54);
}
.no-line-height {
@include font-size(62px, false);
}
.default-vertical-rhythm {
font-size: 62px;
font-size: 3.875rem;
line-height: 1.16129; }
.explict-line-height {
font-size: 62px;
font-size: 3.875rem;
line-height: 0.87097; }
.no-line-height {
font-size: 62px;
font-size: 3.875rem; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment