Created
December 10, 2020 19:12
-
-
Save 06b/3118a468830057981513a07c19f60127 to your computer and use it in GitHub Desktop.
How to calculate a decreased line-height for wrapped headlines when using a typographic scale.
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
:root { | |
--phi: 1.618033988749895; | |
--perfect-fourth: calc(4/3); | |
} | |
html { | |
line-height: 1.5; | |
line-height: var(--phi); | |
} | |
h1, | |
h2, | |
h3, | |
h4, | |
h5, | |
h6 { | |
line-height: 1.125; | |
/** | |
* Theorem: | |
* If a typographic scale is used then it is possible to calculate a decreased line-height for wrapped headlines | |
* by dividing the current line-height by the ratio of the typographic scale. | |
* | |
* π Γ· π = π« | |
* | |
* Proof: | |
* πΉ β {πβΏ,πβΏβΊΒΉ,πβΏβΊΒ²,β¦}, πβΏβΊΒΉ Γ· πβΏ = π, π Γ π = π β π Γ· π = (πΓπ«) β (πΓπ«) Γ· π = π« β π« = π Γ· π.β | |
* | |
* Let πΉ denote a set of values in which represent a typographic scale, | |
* π denote a value within πΉ that represents the font-size absolute length with the unit identifier omitted, | |
* π denote the ratio of the typographic scale between πβΏ & πβΏβΊΒΉ, | |
* π denote a (~) unitless line-height, | |
* π denote the computed value of πΓπ, | |
* and finally π« denote the decreased line-height. | |
* | |
* Case 1: | |
* Assume πΉ β {19, 25.333, 33.777,β¦} where πβΏβΊΒΉ = 33.777 & πβΏ = 25.333. | |
* 33.777 Γ· 25.333 β 1.333 = π, which can also be viewed as π β (4/3) β 1.333. | |
* π = 19 & π = 1.5 β 19 Γ 1.5 = π β π = 28.5 β | |
* 28.5 Γ· (4/3) = 21.375 = (πΓπ«) β | |
* 21.375 Γ· 19 = 1.125 = π« β | |
* 1.125 = 1.5 Γ· 1.333.β | |
* | |
* Case 2: | |
* Assume π = (4/3), π = Ο where β 1.6180339887β¦, | |
* π Γ· π = π« β Ο Γ· π, | |
* 1.6180339887β¦ Γ· (4/3) β 1.213525β¦β | |
* | |
*/ | |
line-height: calc(var(--phi)/var(--perfect-fourth)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment