Combine extend and mixin in with same rules

后端 未结 1 987
Happy的楠姐
Happy的楠姐 2020-12-22 04:40

Okey! I have couple of extends in sass like

%heading
%paragraph
%gutter

and so on...

I want to reuse thouse in media queries, but t

1条回答
  •  借酒劲吻你
    2020-12-22 04:53

    No, you can't combine them that way. You'll have to write a mixin that is invoked by your extend class and anything inside of a media query.

    @mixin my-extend {
        background: yellow;
    }
    
    %my-extend {
        @include my-extend;
    }
    
    .foo {
        @extend %my-extend;
    }
    
    .bar {
        @extend %my-extend;
    }
    
    .baz {
        @media (min-width: 30em) {
            @include my-extend;
        }
    }
    

    Output:

    .foo, .bar {
      background: yellow;
    }
    
    @media (min-width: 30em) {
      .baz {
        background: yellow;
      }
    }
    

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