How to use a Stylus variable in calc?

前端 未结 2 2049

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-s         


        
2条回答
  •  难免孤独
    2020-12-24 05:08

    To use multiple variables (not just one) in calc (or with other functions), i use sprintf as you used, but with tuples:

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

    Remember that interpolation in Stylus is supported through {} and it's used for other kind of interpolation. It's used to surround an expression, which then becomes part of a identifier, or a selector.

提交回复
热议问题