Skip to content

Instantly share code, notes, and snippets.

@cristianferrarig
Last active December 14, 2015 13:48
Show Gist options
  • Save cristianferrarig/5096026 to your computer and use it in GitHub Desktop.
Save cristianferrarig/5096026 to your computer and use it in GitHub Desktop.
Remove unit in SASS
// extract to https://gist.github.com/moyarich/3260638
@function remove-unit($target){
$one:1;
@if not unitless($target){
// Find out the unit of measurement being used
@if (unit($target) == "px"){ $one:1px; }
@elseif (unit($target) == "em"){ $one:1em; }
@elseif (unit($target) == "%" ){ $one:1%; }
// Dividing by the same unit forces sass to return a value with no unit
@return $target / $one ;
}
@else {
@return $target;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment