Skip to content

Instantly share code, notes, and snippets.

@heanfig
Created March 28, 2022 16:16
Show Gist options
  • Save heanfig/a55ca7934556da2400e979291aeb0b31 to your computer and use it in GitHub Desktop.
Save heanfig/a55ca7934556da2400e979291aeb0b31 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@function length($number, $unit) {
$strings: 'px' 'cm' 'mm' '%' 'ch' 'pica' 'in' 'em' 'rem' 'pt' 'pc' 'ex' 'vw' 'vh' 'vmin' 'vmax';
$units: 1px 1cm 1mm 1% 1ch 1pica 1in 1em 1rem 1pt 1pc 1ex 1vw 1vh 1vmin 1vmax;
$index: index($strings, $unit);
@if not $index {
@warn "Unknown unit `#{$unit}`.";
@return false;
}
@return $number * nth($units, $index);
}
@function calculateRem($size) {
$parentSize : 23px;
$remSize: $size / $parentSize;
@return length($remSize,'rem');
}
body {
width: (calculateRem(16px) - calculateRem(23px) / 5rem);
}
body {
width: 0.4956521739rem;
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment