Skip to content

Instantly share code, notes, and snippets.

@webdesignberlin
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdesignberlin/15f6fed1c015040bdb4d to your computer and use it in GitHub Desktop.
Save webdesignberlin/15f6fed1c015040bdb4d to your computer and use it in GitHub Desktop.
responsive typography mixin
$debug: false;
// Variables
$responsive-typo__max-width: 1440px !default;
$responsive-typo__small-screen-width: 480px !default;
$responsive-typo__base-html-font-size: 87.5% !default;
$responsive-typo__step: 10px !default;
$responsive-typo__font-size-step: 1% !default;
@mixin responsive-typo {
$steps: ($responsive-typo__max-width - $responsive-typo__small-screen-width) / $responsive-typo__step;
@for $step-i from 0 through $steps {
$viewport-width: $responsive-typo__small-screen-width + $step-i * $responsive-typo__step;
$font-size: $responsive-typo__base-html-font-size + $step-i * $responsive-typo__font-size-step;
// set's the html font-size
@media (min-width: $viewport-width) {
font-size: $font-size;
@if ($debug) {
&:before {
content: "min-width: #{$viewport-width}, font-size: #{$font-size} step: #{$step-i}";
}
}
}
}
@if ($debug) {
&:before {
position: fixed;
top: 1rem;
left: 1rem;
color: red;
}
}
}
html {
@include responsive-typo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment