Last active
          June 27, 2024 07:55 
        
      - 
      
 - 
        
Save SvenJuergens/1a3cf4fc38f796180d04f006986f97b7 to your computer and use it in GitHub Desktop.  
    Responsive font calculator as scss mixin (based on https://websemantics.uk/tools/fluid-responsive-property-calculator/)
  
        
  
    
      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
    
  
  
    
  | /* based on https://websemantics.uk/tools/fluid-responsive-property-calculator/ */ | |
| // Base for responsive calculation: Specifies the minimum and maximum size | |
| // for which the size should be dynamically created | |
| $min-vw: 375; | |
| $max-vw: 1250; | |
| @mixin responsive-property($min-value, $max-value,$property: font-size) { | |
| $slope: math.div(($max-value - $min-value), ($max-vw - $min-vw)); | |
| $base: $min-value - ($slope * $min-vw); | |
| #{$property}: clamp(#{$min-value}px, calc(#{$base}px + #{$slope * 100}vw), #{$max-value}px); | |
| } | |
| // Example usage | |
| //.responsive-element { | |
| // @include responsive-property(100, 200); // default property is font-size | |
| // @include responsive-property(10, 50, padding); | |
| // @include responsive-property(5, 25, margin); | |
| // ... | |
| //} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment