Created
July 7, 2020 17:05
-
-
Save hihayk/056bdb2b2964fab8a73420572ee991cd to your computer and use it in GitHub Desktop.
Dynamically decrease line-height as the font-size grows.
This file contains hidden or 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
:root { | |
--lineHeightFixedAmount: 0.25rem; | |
--lineHeightRelativeAmount: 1em; | |
--sizesIncrement: 1.4; | |
--fontSize-0: 1rem; | |
--fontSize-1: calc(var(--fontSize-0) * var(--sizesIncrement)); | |
--fontSize-2: calc(var(--fontSize-1) * var(--sizesIncrement)); | |
--globalLineHeight: calc(var(--lineHeightFixedAmount) + var(--lineHeightRelativeAmount)); | |
--globalFontSize: var(--fontSize-0); | |
} | |
* { | |
line-height: var(--globalLineHeight); | |
} | |
html { | |
font-size: 100%; | |
} | |
body { | |
font-size: var(--globalFontSize); | |
} | |
.textSize-2 { | |
font-size: var(--fontSize-2); | |
} | |
.textSize-1 { | |
font-size: var(--fontSize-1); | |
} | |
.textSize-0 { | |
font-size: var(--fontSize-0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment