Last active
December 14, 2015 13:48
-
-
Save cristianferrarig/5096026 to your computer and use it in GitHub Desktop.
Remove unit in SASS
This file contains 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
// 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