Conditionally setting one variable's value based on another

后端 未结 3 1904
天涯浪人
天涯浪人 2020-12-03 22:14

I\'ve got a Less variable called @side. What I want is to set the variable @sideOpposite depending on the value of the @side variable.

3条回答
  •  囚心锁ツ
    2020-12-03 23:00

    You can take help of the mixin guard feature to allow conditional mixins

    .mixin (@side; @sideOpposite) when (@side = right) { @sideOpposite: left }
    .mixin (@side; @sideOpposite) when (@side = left) { @sideOpposite: right }
    

提交回复
热议问题