How to use a Stylus variable in calc?

匆匆过客 提交于 2019-11-30 01:10:47

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

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 interepolation 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!