Last active
August 29, 2015 14:01
-
-
Save davethegr8/a95d66e455de81f34c17 to your computer and use it in GitHub Desktop.
simple LESS mixin for typographic scales
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
// Based on the work of Tim Brown from http://alistapart.com/article/more-meaningful-typography | |
@fontRatioBase: 16; //In pixels | |
@fontRatioScale: 1.618; | |
.font-rem(@size) { | |
font-size: @size * @fontRatioBase * 1px; | |
font-size: @size * 1rem; | |
} | |
.font-scale(@index, @base: @fontRatioBase, @scale: @fontRatioScale) { | |
font-size: pow(@scale, @index) * 1rem; | |
font-size: @base * pow(@scale, @index) * 1px; | |
} | |
.font-scale-double(@index, @base: @fontRatioBase, @scale: @fontRatioScale) { | |
font-size: pow(@scale, @index) * 2rem; | |
font-size: @base * pow(@scale, @index) * 2px; | |
} | |
/* Usage */ | |
html { | |
font-size: @fontRatioBase * 1px; | |
line-height: 1.35; | |
} | |
h1 { | |
.font-scale(1); // 25.888px | |
} | |
p { | |
.font-scale(0); // 16px | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment