How can I pass an expression to a calc() mixin that uses Sass variables -


i have mixin set cross browser calc,

@mixin calc($property, $expression...) {    #{$property}: -moz-calc(#{$expression});    #{$property}: -o-calc(#{$expression});    #{$property}: -webkit-calc(#{$expression});    #{$property}: calc(#{$expression});  }  

i have variable.

$line: 12px; 

i want able use variable within it.

@include calc(width, "30% - ( $line * 2) ) "); 

but i'm not sure if that's best way go it.

you'll need use string interpolation on value you're passing 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); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -