Scss : Selector Inheritance : removing one declaration

后端 未结 1 1686
梦谈多话
梦谈多话 2020-12-21 23:05

Is there a way to remove the declaration from the extended selector in scss?

Example would be:

#logo {
  float: left;
  width: 75px;
  height: 28px;
         


        
相关标签:
1条回答
  • 2020-12-21 23:43

    There is no "undo". you'll have to create a separate selector that both selectors extend from:

    %logo-common {
      float: left;
      width: 75px;
      height: 28px;
    }
    
    #logo {
      @extend %logo-common;
      background: url("/images/logo.png") no-repeat 0 0;
      a {
        @extend %logo-common;
        display: block;
        text-decoration: none;
        text-indent: -999999em;
        overflow: hidden;
      }
    }
    

    Compiles to:

    #logo, #logo a {
      float: left;
      width: 75px;
      height: 28px;
    }
    
    #logo {
      background: url("/images/logo.png") no-repeat 0 0;
    }
    #logo a {
      display: block;
      text-decoration: none;
      text-indent: -999999em;
      overflow: hidden;
    }
    
    0 讨论(0)
提交回复
热议问题