Dynamic Variable Names in LESS CSS

后端 未结 1 1445
小蘑菇
小蘑菇 2020-12-11 00:17

I have been trying this for a while, looking at other answers, but to no avail. Hopefully someone can help me.

I am trying to generate some dynamic variable names wi

1条回答
  •  有刺的猬
    2020-12-11 01:20

    You can use Variable Names. And I've tested the code at http://lesstester.com/, it works.

    @horizontal-default-color: #fff;
    @horizontal-inverse-color: #000;
    
    .horizontal-variant(@variant) {
      @color: "horizontal-@{variant}-color";
      color: @@color;
    }
    
    .horizontal-default{
      .horizontal-variant(default);
    }
    .horizontal-inverse{
      .horizontal-variant(inverse);
    }
    

    0 讨论(0)
提交回复
热议问题