Last active
August 29, 2015 14:23
-
-
Save eduardoboucas/371f04bd49c44dae26c6 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
// ---- | |
// Sass (v3.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
/// | |
/// Viewport sized typography with minimum and maximum values | |
/// | |
/// @author Eduardo Boucas (@eduardoboucas) | |
/// | |
/// @param {Number} $responsive - Viewport-based size | |
/// @param {Number} $min - Minimum font size (px) | |
/// @param {Number} $max - Maximum font size (px) | |
/// (optional) | |
/// @param {Number} $fallback - Fallback for viewport- | |
/// based units (optional) | |
/// | |
/// @example scss - 5vw font size (with 50px fallback), | |
/// minumum of 35px and maximum of 150px | |
/// @include responsive-font(5vw, 35px, 150px, 50px); | |
/// | |
@mixin responsive-font($responsive, $min, $max: false, $fallback: false) { | |
$responsive-unitless: $responsive / ($responsive - $responsive + 1); | |
$dimension: if(unit($responsive) == 'vh', 'height', 'width'); | |
$min-breakpoint: $min / $responsive-unitless * 100; | |
@media (max-#{$dimension}: #{$min-breakpoint}) { | |
font-size: $min; | |
} | |
@if $max { | |
$max-breakpoint: $max / $responsive-unitless * 100; | |
@media (min-#{$dimension}: #{$max-breakpoint}) { | |
font-size: $max; | |
} | |
} | |
@if $fallback { | |
font-size: $fallback; | |
} | |
font-size: $responsive; | |
} | |
// -------------------- DEMO -------------------------- | |
body { | |
@include responsive-font(5vw, 35px, 150px); | |
} |
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
body { | |
font-size: 5vw; | |
} | |
@media (max-width: 700px) { | |
body { | |
font-size: 35px; | |
} | |
} | |
@media (min-width: 3000px) { | |
body { | |
font-size: 150px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment