Skip to content

Instantly share code, notes, and snippets.

@ryanjames
Last active August 29, 2015 14:05
Show Gist options
  • Save ryanjames/a4a2052195b284c8c23a to your computer and use it in GitHub Desktop.
Save ryanjames/a4a2052195b284c8c23a to your computer and use it in GitHub Desktop.
Vertical rhythm mixin
// Throw a font size into this mixin and get optimal line heights and top/bottom margins.
// Adjustable variables to fine-tune.
@mixin vertical-rhythm($size) {
$st: 12px; // Smallest text size
$sh: 140%; // Optimal line height for smallest text size
$lt: 70px; // Largest text size
$lh: 100%; // Optimal line height for largest text size
$text-size-percent: ($size - $st)/($lt - $st) * 100;
$new-line-height: $sh - ((($sh - $lh) * $text-size-percent) / 100);
font-size: $size; // Omit if you want to set font size somewhere else
line-height: $new-line-height;
margin: (48px/$size)*4px 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment