How to use a Stylus variable in calc?

aknuds1 picture aknuds1 · Aug 28, 2015 · Viewed 19.1k times · Source

In Stylus, how do I use a variable in a calc expression?

For example, the following doesn't work (arrow-size being a variable):

arrow-size = 5px
left calc(50% - arrow-size)

Answer

aknuds1 picture aknuds1 · Aug 28, 2015

In order to use a Stylus variable inside a calc expression, one must employ the string % operator:

arrow-size = 5px
left "calc(50% - %s)" % arrow-size