Skip to content

Instantly share code, notes, and snippets.

@xl1
Created July 14, 2012 14:04
Show Gist options
  • Save xl1/3111497 to your computer and use it in GitHub Desktop.
Save xl1/3111497 to your computer and use it in GitHub Desktop.
SCSS で単位を落とす
/*
@function int($x) {
$list: ();
@for $i from floor($x - $x) to floor($x) {
$list: append($list, 0);
}
@return length($list);
}
*/
// もっとよいやり方がある
@function num($x){
@return $x / (1 + $x - $x);
}
@debug num(1px); // -> 1
@debug num(40em); // -> 40
@debug num(23.4%); // -> 23.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment