Created
November 29, 2017 15:35
-
-
Save Elvenmagic/3d90bcca40c17b30d036cae69777d054 to your computer and use it in GitHub Desktop.
Responsive vh/vw based font sizes
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
@mixin responsive-font($responsive, $min, $max: false, $fallback: false) { | |
$responsive-unitless: $responsive / ($responsive - $responsive + 1); | |
$dimension: if(unit($responsive) == 'vh', 'height', 'width'); | |
$min-breakpoint: $min / $responsive-unitless * 100; | |
@media (max-#{$dimension}: #{$min-breakpoint}) { | |
font-size: $min; | |
} | |
@if $max { | |
$max-breakpoint: $max / $responsive-unitless * 100; | |
@media (min-#{$dimension}: #{$max-breakpoint}) { | |
font-size: $max; | |
} | |
} | |
@if $fallback { | |
font-size: $fallback; | |
} | |
font-size: $responsive; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment