2014-03-26 11 views
31

Ich habe einen :not CSS-Selektor in SASS mixin aber es tut nichts:SASS: nicht Wähler

Code Snippet:

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

Die .notip Klasse wird erstellt, aber keine CSS generiert für :not(.notip).

+0

Stellen Sie sicher, dass Sie genug Code zur Verfügung stellen, die dies tatsächlich kompilieren wird (fehlende Variablen, Mixins, etc.). Außerdem ist das Problem nicht reproduzierbar. – cimmanon

Antwort

40

Ich habe versucht, diese neu zu erstellen, und .someclass.notip für mich erzeugt wurde aber .someclass:not(.notip) war so lange nicht, wie ich nicht die @mixin tip() definiert hatte. Sobald ich das hatte, hat alles funktioniert.

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(); } 

EDIT:http://sassmeister.com/ ist ein guter Ort, um Ihre SASS zu debuggen, weil es Fehlermeldungen gibt. Undefined mixin 'tip'. es, was ich bekomme, wenn ich entferne @mixin tip($pos:right) { }

+0

Vielen Dank .. – user2667409