Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SASS :not selector

I have a :not css selector in SASS mixin but it doesn't do anything:

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

The .notip class is being generated but no CSS is being generated for :not(.notip).

like image 391
user2667409 Avatar asked Mar 26 '14 02:03

user2667409


People also ask

Is not SCSS?

:not() Back :not() is a CSS negation pseudo-class selector. It is a functional pseudo-class selector that takes a simple selector as an argument, and then matches one or more elements that are not represented by the argument.

What is not () in CSS?

:not() The :not() CSS pseudo-class represents elements that do not match a list of selectors. Since it prevents specific items from being selected, it is known as the negation pseudo-class. /* Selects any element that is NOT a paragraph */ :not(p) { color: blue; }

Has selector in Sass?

The :has() CSS pseudo-class represents an element if any of the selectors passed as parameters (relative to the :scope of the given element), match at least one element. The :has() pseudo-class takes a selector list as an argument.

Which is not the selector type of CSS?

The :not() property in CSS is a negation pseudo class and accepts a simple selector or a selector list as an argument. It matches an element that is not represented by the argument. The passed argument may not contain additional selectors or any pseudo-element selectors.


1 Answers

I tried re-creating this, and .someclass.notip was being generated for me but .someclass:not(.notip) was not, for as long as I did not have the @mixin tip() defined. Once I had that, it all worked.

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/ is a good place to debug your SASS because it gives you error messages. Undefined mixin 'tip'. it what I get when I remove @mixin tip($pos:right) { }

like image 174
Ming Avatar answered Sep 24 '22 13:09

Ming