0

I am looking at the mixin documentation and have created a simple mixin

@mixin mobile-pos($property, $offset) {
    // Fallback
    #{$property}: calc(100vh - $offset);

    // Better - for browsers that support custom css vars
    #{$property}: calc(var(--rvh) * 100 - $offset);
}

Here is how I'm using the mixin

#container-circles {
    bottom: unset;
    @include mobile-pos(top, 90px);
}

I checked the compiled CSS output

#container-circles {
  bottom: unset;
  top: calc(100vh - $offset);
  top: calc(var(--rvh) * 100 - $offset); }

Any idea why the second param is not getting compiled properly? I'm using node-sass 4.11.0

quickshiftin
  • 66,362
  • 10
  • 68
  • 89

1 Answers1

0

Using $variables inside your calc() is like this

SCSS

    @mixin mobile-pos($property, $offset) {
      // Fallback
      #{$property}: calc(100vh - #{$offset});

      // Better - for browsers that support custom css vars
      #{$property}: calc(var(--rvh) * 100 - #{$offset});
    }
Ganesa Vijayakumar
  • 2,422
  • 5
  • 28
  • 41