Last active
August 29, 2015 14:07
-
-
Save webdesignberlin/15f6fed1c015040bdb4d to your computer and use it in GitHub Desktop.
responsive typography mixin
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
$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