2014-03-26 51 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