Skip to content

Instantly share code, notes, and snippets.

@nikosolihin
Forked from zboralski/_resp-scale.scss
Last active August 29, 2015 14:07
Show Gist options
  • Save nikosolihin/8768ac136fd77cd9219c to your computer and use it in GitHub Desktop.
Save nikosolihin/8768ac136fd77cd9219c to your computer and use it in GitHub Desktop.
// 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