-1

Say I have two CSS classes:

.class1 {
   color: red;
}

.class2 {
  /* Has Stuff */
}

I only want to apply whatever styles class1 has IF class2 is not also on the element. So for example:

<div class="class1">Some div</div>

Should be in red.

However, if I do:

<div class="class1 class2">Some div</div>

Should NOT be red, even if class2 doesn't have anything related defined in it.

How can I do this?

theJuls
  • 6,788
  • 14
  • 73
  • 160

1 Answers1

3
.class1:not(.class2) {
   color: red;
}

This should work for you

Łukasz Blaszyński
  • 1,536
  • 1
  • 8
  • 13