Last active
April 19, 2024 14:39
-
-
Save rniswonger/72e993bdd0c475951ca4b2d68b3c07a6 to your computer and use it in GitHub Desktop.
Sass Mixin: Fluid Text
This file contains hidden or 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
// fluidly resize type | |
// based on example here https://css-tricks.com/snippets/css/fluid-typography/ | |
@mixin fluid-type($font-min, $font-max, $screen-min, $screen-max) { | |
font-size: #{$font-min}px; | |
@media only screen and (min-width: #{$screen-min}px) { | |
font-size: calc( | |
#{$font-min}px + #{($font-max - $font-min)} * (100vw - #{$screen-min}px) / (#{$screen-max} - #{$screen-min}) | |
); | |
} | |
@media only screen and (min-width: #{$screen-max}px) { | |
font-size: #{$font-max}px; | |
} | |
} | |
.my-text { | |
@include fluid-type(16, 32, 480, 1500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment