Skip to content

Instantly share code, notes, and snippets.

@maxxscho
Created August 31, 2017 09:30
Show Gist options
  • Save maxxscho/6f70e51f9dbe3af3652a7d07f41d7310 to your computer and use it in GitHub Desktop.
Save maxxscho/6f70e51f9dbe3af3652a7d07f41d7310 to your computer and use it in GitHub Desktop.
Strips the unit of a value in SCSS
/// Remove the unit of a length
/// @param {Number} $number - Number to remove unit from
/// @return {Number} - Unitless number
@function strip-unit($number) {
@if type-of($number) == 'number' and not unitless($number) {
@return $number / ($number * 0 + 1);
}
@return $number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment