Skip to content

Instantly share code, notes, and snippets.

@munkacsitomi
Created August 23, 2019 21:49
Show Gist options
  • Save munkacsitomi/d4cc79aff42a00081cf3b8e03def39e5 to your computer and use it in GitHub Desktop.
Save munkacsitomi/d4cc79aff42a00081cf3b8e03def39e5 to your computer and use it in GitHub Desktop.
Responsive font
@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;
}
@include responsive-font(5vw, 35px, 150px, 50px);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment