Created
July 23, 2020 20:15
-
-
Save cherifGsoul/5058f6e9efe15f8e41de443d1788d465 to your computer and use it in GitHub Desktop.
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
$base-font-size: 16px; | |
$base-line-height: 1.5; | |
$rhythm-line: round($base-font-size * $base-line-height); // in pixels | |
$caps-height: 0.68; | |
@function calculate-lines-for-size($font-size) { | |
// Returns unitless value | |
@return ceil(($font-size + 0.001) / $rhythm-line); | |
} | |
@function calculate-line-height($font-size) { | |
$lines-count: calculate-lines-for-size($font-size); | |
@return round($rhythm-line * $lines-count); | |
} | |
@function calculate-padding-top($font-size) { | |
$line-height: calculate-line-height($font-size); | |
@return ($line-height - ($font-size * $caps-height)) / 2; | |
} | |
@function calculate-margin-bottom($font-size) { | |
$padding-top: calculate-padding-top($font-size); | |
@return $rhythm-line - $padding-top; | |
} | |
@mixin vertical-rhythm($font-size: $base-font-size) { | |
font-size: round($font-size); | |
line-height: round(calculate-line-height(round($font-size))); | |
padding-top: round(calculate-padding-top(round($font-size))); | |
margin-bottom: round(calculate-margin-bottom(round($font-size))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment