【问题标题】:SASS :not selectorSASS:不是选择器
【发布时间】:2015-09-21 18:00:07
【问题描述】:

我在 SASS mixin 中有一个 :not css 选择器,但它什么也没做:

代码片段:

@mixin dropdown-pos($pos:right) {
  &:not(.notip) {
    @if $comp-tip == true{
      @if $pos == right {
        top:$dropdown-width * -0.6;
        @include tip($pos:$pos);
      }
    }
  }
  &.notip {
    @if $pos == right {
      top: 0;
      left:$dropdown-width * 0.8;
    }
  }
}

正在生成 .notip 类,但没有为 :not(.notip) 生成 CSS。

【问题讨论】:

  • 确保您提供了足够的代码以便实际编译(缺少变量、mixins 等)。此外,该问题不可重现。

标签: css sass compass-sass


【解决方案1】:

我尝试重新创建它,并且 .someclass.notip 正在为我生成但 .someclass:not(.notip) 没有,只​​要我没有定义 @mixin tip()。一旦我有了它,一切都奏效了。

http://sassmeister.com/gist/9775949

$dropdown-width: 100px;
$comp-tip: true;

@mixin tip($pos:right) {

}

@mixin dropdown-pos($pos:right) {
  &:not(.notip) {
    @if $comp-tip == true{
      @if $pos == right {
        top:$dropdown-width * -0.6;
        background-color: #f00;
        @include tip($pos:$pos);
      }
    }
  }
  &.notip {
    @if $pos == right {
      top: 0;
      left:$dropdown-width * 0.8;
      background-color: #00f;
    }
  }
}

.someclass { @include dropdown-pos(); }

编辑:http://sassmeister.com/ 是调试 SASS 的好地方,因为它会为您提供错误消息。 Undefined mixin 'tip'. 这是我删除 @mixin tip($pos:right) { } 时得到的结果

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-25
    • 2018-12-04
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-05
    相关资源
    最近更新 更多