Created
November 21, 2016 18:06
-
-
Save dancek/2eb8f575edfba359f84d2ea450bb6695 to your computer and use it in GitHub Desktop.
Responsively resizing fonts (to keep their size near constant relative to viewport size)
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
.font-mediaqueries (@width-min; @width-max; @font-min; @font-max) when (@width-min < @width-max) { | |
@media only screen and (min-width: round(@width-min)) { | |
body { | |
font-size: @font-min; | |
} | |
} | |
@font-next: @font-min + 1px; | |
@slope: unit(@width-max - @width-min) / unit(@font-max - @font-min); | |
@width-next: (unit(@width-min) + @slope) * 1px; | |
.font-mediaqueries(@width-next; @width-max; @font-next; @font-max); | |
} | |
.font-mediaqueries(360px, 768px, 10px, 20px); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment