Last active
November 7, 2022 14:54
-
-
Save krstivoja/99d5f480c77bda63386040ff8c4d2cb8 to your computer and use it in GitHub Desktop.
TypeClamp SCSS Mixin
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
// CSS taken from: https://websemantics.uk/tools/responsive-font-calculator/ | |
// Set up Min - Max Viewport (without px) | |
$viewport-min: 800; | |
$viewport-max: 1680; | |
// TypeClamp Mixin | |
@mixin typeclamp ($min, $max){ | |
font-size: clamp( | |
#{$min}px, | |
calc(1rem + (#{$max} - #{$min}) * ((100vw - #{$viewport-min}px) / (#{$viewport-max} - #{$viewport-min}))), | |
#{$max}px); | |
min-height: 0vw; | |
} | |
// Example usage | |
h1{ | |
@include typeclamp(30, 120); | |
} |
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
h1 { | |
font-size: clamp( 30px, calc(1rem + (120 - 30) * ((100vw - 800px) / (1680 - 800))), 120px); | |
min-height: 0vw; | |
} |
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
{ | |
"sass": { | |
"compiler": "dart-sass/1.32.12", | |
"extensions": {}, | |
"syntax": "SCSS", | |
"outputStyle": "expanded" | |
}, | |
"autoprefixer": false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment