Skip to content

Instantly share code, notes, and snippets.

@dancek
Created November 21, 2016 18:06
Show Gist options
  • Save dancek/2eb8f575edfba359f84d2ea450bb6695 to your computer and use it in GitHub Desktop.
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)
.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