Skip to content

Instantly share code, notes, and snippets.

@eloyesp
Last active October 7, 2021 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eloyesp/0d038cccba3ebd2428c0e17e36992405 to your computer and use it in GitHub Desktop.
Save eloyesp/0d038cccba3ebd2428c0e17e36992405 to your computer and use it in GitHub Desktop.
Micro Responsive Font Size
/* Simplified Responsive Font Size
* Usage is @include rfs(1.2rem);
* Used to embed when import is not available.
* Based on https://github.com/twbs/rfs
*/
@mixin rfs($value, $property: font-size) {
// Check value is in **rem**.
@if unit($value) != rem {
@error "`#{$value}` has not a valid unit. Use `rem`."
}
// Hardcoded config
$base: 1rem;
// Calculate the minimum value
$min: $base + $value / 10;
@if $min >= $value {
#{$property}: $value;
} @else {
// Calculate the variable part
$variable: #{ ($value * 0.9 - $base) / 0.75rem }vw;
#{$property}: calc(#{$min} + #{$variable});
@media (min-width: 1200px) {
#{$property}: $value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment