How to pass a property name as an argument to a mixin in less

前端 未结 4 1291
说谎
说谎 2020-12-06 21:11

I want to make a function/mixin that will make a color darker if it is already dark but lighter when it is light (normalize/extremeize?)

Is it possible to do this by

4条回答
  •  太阳男子
    2020-12-06 21:45

    This feature was added since v1.6.0:

    @property: color;
    
    .widget {
      @{property}: #0ee;
      background-@{property}: #999;
    }
    

    Compiles to:

    .widget {
      color: #0ee;
      background-color: #999;
    }
    

    See http://lesscss.org/features/#variables-feature-properties

提交回复
热议问题