Skip to content

Instantly share code, notes, and snippets.

@krypton225
Last active May 10, 2023 19:13
Show Gist options
  • Select an option

  • Save krypton225/12a5bd7b74ba66756b374a29f429995e to your computer and use it in GitHub Desktop.

Select an option

Save krypton225/12a5bd7b74ba66756b374a29f429995e to your computer and use it in GitHub Desktop.
Useful functions in SCSS.
@function get-half($number) {
@return $number / 2;
}
@function square($number) {
@return $number * $number;
}
@function rem($px-val) {
$rem-val: $px-val / $base-fz;
$safe-rem-value: if($px-val == 0, 0, $rem-val);
@return $zero-safe-rem-value;
}
/*
* This code belongs to: Kitty Giraudel.
* You can see that in: https://css-tricks.com/snippets/sass/strip-unit-function/
* We updated the using of math lib of sass.
*/
@function strip-unit($num) {
@if type-of($num) == "number" and not unitless($num) {
@return math.div($num, ($num * 0 + 1));
}
@return $num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment