SASS variables and inheritance

前端 未结 4 468
盖世英雄少女心
盖世英雄少女心 2021-01-07 03:13

Suppose I have two virtually identical HTML structures, but with different class names. They only differ by a few variables, like width and h

4条回答
  •  一个人的身影
    2021-01-07 03:42

    Your problem can be solved by using a mixin.

    @mixin button($width){
      button{
        background:red;
        width:$width;
      }
    }
    
    .widget-a{ @include button(50px);  }
    
    .widget-b{ @include button(100px); }
    

提交回复
热议问题