2014-03-26 52 views
31

我在SASS混入一个:not CSS选择器,但它不会做任何事情:SASS:不选择器

代码段:

@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类,但没有CSS是正在为:not(.notip)生成。

+0

确保你提供了足够的代码,这将实际编译(缺少变量,mixins等)。此外,问题不可重现。 – cimmanon

回答

40

我试图重新创建这个,并且.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) { }

+0

非常感谢。 – user2667409