Scss:Selector继承:删除一个声明

时间:2013-08-19 18:45:05

标签: inheritance sass

有没有办法从scss中的扩展选择器中删除声明?

示例是:

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

而不是使用

  

background:none;

1 个答案:

答案 0 :(得分:3)

没有“撤消”。你必须创建一个单独的选择器,两个选择器都从:

扩展
%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;
  }
}

编译为:

#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;
}