aknuds1 aknuds1 - 2 months ago 43
CSS Question

How to use a Stylus variable in calc?

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

In order to use a Stylus variable inside a calc expression, one must use string interpolation:

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