Skip to content

Instantly share code, notes, and snippets.

@zhouzi

zhouzi/ms.scss Secret

Last active September 13, 2015 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhouzi/2ab48c9b30b2a1a93c72 to your computer and use it in GitHub Desktop.
Save zhouzi/2ab48c9b30b2a1a93c72 to your computer and use it in GitHub Desktop.
Modular scale for font sizing with power math function
// http://www.modularscale.com/
// http://webdesign.tutsplus.com/articles/how-to-establish-a-modular-typographic-scale--webdesign-14927
@function pow ($x, $n) {
$ret: 1;
@if $n >= 0 {
@for $i from 0 to $n {
$ret: $ret * $x;
}
} @else {
@for $i from $n to 0 {
$ret: $ret / $x;
}
}
@return $ret;
}
@function ms ($n, $base: $ms-base, $ratio: $ms-ratio) {
@return pow($ratio, $n) * $base;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment