Skip to content

Instantly share code, notes, and snippets.

@travis-g
Created August 13, 2015 20:15
Show Gist options
  • Save travis-g/ad4aa02ba83f4e40fe88 to your computer and use it in GitHub Desktop.
Save travis-g/ad4aa02ba83f4e40fe88 to your computer and use it in GitHub Desktop.
SCSS class for responsive and fluidly-resizing text
// smallest font size:
$font-size: 100%;
// minimum width before resizing rules apply:
$min-width: 340px;
// the range in width to create the resizing steps:
$range: 600px;
// number of resizing steps to make (more steps yields more fluid resizing):
$steps: 10;
// calculate the width of each step:
$step-size: $range / $steps;
.responsive-text {
$i: 0;
@while $i <= $steps {
@media only screen and (min-width : $min-width + ($i * $step-size)) {
// increase font size by 2% each step:
font-size: $font-size * (1 + (.02 * $i));
}
$i: $i + 1;
}
@media only screen and (max-width: $min-width) {
// for screens smaller than $min-width:
font-size: $font-size;
}
}
html {
@extend.responsive-text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment