Skip to content

Instantly share code, notes, and snippets.

@1xtr
Last active January 27, 2022 11:16
Show Gist options
  • Save 1xtr/e99b161e6e2dc56b4f5126d6739f03b1 to your computer and use it in GitHub Desktop.
Save 1xtr/e99b161e6e2dc56b4f5126d6739f03b1 to your computer and use it in GitHub Desktop.
Fluid font size
// 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