Last active
July 17, 2017 17:42
-
-
Save jonnymaceachern/a07a7fda3387ca7cdc1c96945ef472b1 to your computer and use it in GitHub Desktop.
Fluid font-sizes
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
/// Remove the unit of a length | |
/// @param {Number} $number - Number to remove unit from | |
/// @return {Number} - Unitless number | |
@function strip-unit($number) { | |
@if type-of($number) == 'number' and not unitless($number) { | |
@return $number / ($number * 0 + 1); | |
} | |
@return $number; | |
} |
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
// ----------------------------------------------------------------------------- | |
// Fluid font size | |
// ----------------------------------------------------------------------------- | |
@mixin fluid-font-size($min, $max) { | |
font-size: $min; | |
@include mq(xs) { | |
font-size: calc(#{$min} + #{strip-unit($max - $min)} * ((100vw - #{map-get($mq-breakpoints, xs)}) / (#{strip-unit(map-get($mq-breakpoints, md))}))); | |
} | |
@include mq(md) { | |
font-size: $max; | |
} | |
} |
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
.lead { | |
margin-bottom: 25px; | |
font-weight: 300; | |
@include fluid-font-size(14px, 22px); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment