Stylus escape all the content of calc function
/* .stylus */
.test1
$offset = 5px
$mult = 3
height calc(1em + $offset * $mult)
/* .css */
.test1 {
height: calc(1em + $offset * $mult);
}
so you can use sprintf-like operator %
but it's not realy easy te read
/* .stylus */
.test2
$offset = 5px
$mult = 3
height 'calc(1em + %s * %s)' % ($offset $mult)
/* .css */
.test2 {
height: calc(1em + 5px * 3);
}
you can create a calc2()
mixin that use calc()
but stylus will try to do the operation
/* .stylus */
calc2($expr...)
'calc(%s)' % $expr
.test3
$offset = 5px
$mult = 3
height calc2(1em + $offset * $mult)
/* .css */
.test3 {
height: calc(16em);
}
so you have to escape all operators. i think it's more readable than sprintf syntax
/* .stylus */
calc2($expr...)
'calc(%s)' % $expr
.test4
$offset = 5px
$mult = 3
height calc2(1em \+ $offset \* $mult)
/* .css */
.test4 {
height: calc(1em + 5px * 3);
}
if you want you can rename the calc2()
mixin calc()
, it's works
/* .stylus */
calc($expr...)
'calc(%s)' % $expr
.test5
$offset = 5px
$mult = 3
height calc(1em \+ $offset \* $mult)
/* .css */
.test5 {
height: calc(1em + 5px * 3);
}
or if you don't want to create a mixin, you can use calc()
with other case ( Calc()
or CALC()
for example)
/* .stylus */
.test6
$offset = 5px
$mult = 3
height Calc(1em \+ $offset \* $mult)
/* .css */
.test6 {
height: Calc(1em + 5px * 3);
}