Created
April 19, 2016 21:19
-
-
Save jhned/2c3fd4747b4abb87fb050a9b0822dc41 to your computer and use it in GitHub Desktop.
Flexible 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
@function strip-unit($value) { | |
@return $value / ($value * 0 + 1); | |
} | |
@mixin flexible_font_sizes( $min-font-size, $max-font-size, $min-width, $max-width ) { | |
$font-size-difference: strip-unit($max-font-size - $min-font-size); | |
$viewport-difference: strip-unit($max-width - $min-width); | |
@media screen and #{breakpoint($min-width)} and #{breakpoint($max-width down)} { | |
font-size: calc( #{$min-font-size} + #{$font-size-difference} * ( ( 100vw - #{$min-width} ) / #{$viewport-difference} ) ); | |
} | |
} | |
.module-with-flexible-sizes { | |
@include flexible_font_sizes( 16px, 20px, 320px, 539px ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment