-
-
Save nikosolihin/8768ac136fd77cd9219c to your computer and use it in GitHub Desktop.
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
// Requires SASS >= 3.3 and responsive.scss | |
// https://gist.github.com/maxluster/168e650267bac9faaafd | |
// | |
// Scale value with $width for each $width in $named-breakpoints map. | |
// Usage : @include responsive("font-size", $base-font-size + px, | |
// resp-scale($base-width, $base-font-size)); | |
@function resp-scale($width, $value, $scale-up: false) { | |
$m : (); | |
@each $k, $v in $named-breakpoints { | |
$ok : true; | |
$v: $v / ($v * 0 + 1); // strip-units | |
@if $v > $width { | |
$ok : $scale-up; | |
} | |
@if $ok { | |
$res : round($v * $value / $width); | |
$m: map-merge($m, ("#{$k}": $res +'px')); | |
} | |
} | |
@return $m; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment