I have a mixin set up to do a cross browser calc,
@mixin calc($property, $expression...) {
#{$property}: -moz-calc(#{$expression});
#{$property}: -o-calc(#{$expression});
#{$property}: -webkit-calc(#{$expression});
#{$property}: calc(#{$expression});
}
I also have a variable.
$line: 12px;
I want to be able to use a variable within it.
@include calc(width, "30% - ( $line * 2) ) ");
But I'm not sure if that's the best way to go about it.
You'll need to use string interpolation on the value you're passing to the mixin:
.foo {
@include calc(width, #{"30% - #{$line * 2}"});
}
Output:
.foo {
width: -moz-calc(30% - 24px);
width: -o-calc(30% - 24px);
width: -webkit-calc(30% - 24px);
width: calc(30% - 24px);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With