1

有没有办法从 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;
  }
}

而不是使用

背景:无;

4

1 回答 1

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;
}
于 2013-08-20T13:38:17.313 回答