Last active
January 27, 2022 11:16
-
-
Save 1xtr/e99b161e6e2dc56b4f5126d6739f03b1 to your computer and use it in GitHub Desktop.
Fluid font size
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
// use | |
// .className | |
// @include fluidFontSize(12, 60, 320, 1440) | |
// | |
@function calcFluidFontSize($f-min, $f-max, $v-min, $v-max) | |
$k: ($f-max - $f-min)/($v-max - $v-min) | |
$b: $f-min - $k * $v-min | |
$b: $b * 1px | |
@return calc( #{$k} * 100vw + #{$b} ) | |
@mixin fluidFontSize($f-min, $f-max, $w-min, $w-max, $fallback: false) | |
font-size: $f-min + px | |
@media (min-width: $w-min+px) | |
@if ($fallback) | |
font-size: $fallback | |
font-size: calcFluidFontSize($f-min, $f-max, $w-min, $w-max) | |
@media (min-width: $w-max+px) | |
font-size: $f-max + px |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment