Skip to content

Instantly share code, notes, and snippets.

@whatjackhasmade
Last active June 5, 2017 11:10
Show Gist options
  • Save whatjackhasmade/2e24799055dcd344ea7ad1a557a8ce89 to your computer and use it in GitHub Desktop.
Save whatjackhasmade/2e24799055dcd344ea7ad1a557a8ce89 to your computer and use it in GitHub Desktop.
Mixin - Not
/*/////////////////////////////////////////
/// NOT
*/////////////////////////////////////////
@mixin not($ignorList...) {
//if only a single value given
@if (length($ignorList) == 1){
//it is probably a list variable so set ignore list to the variable
$ignorList: nth($ignorList,1);
}
//set up an empty $notOutput variable
$notOutput: '';
//for each item in the list
@each $not in $ignorList {
//generate a :not([ignored_item]) segment for each item in the ignore list and put them back to back
$notOutput: $notOutput + ':not(#{$not})';
}
//output the full :not() rule including all ignored items
&#{$notOutput} {
@content;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment