user2952265 user2952265 - 26 days ago 12
Sass (Sass) Question

CSS :not selector has no effect

I want to give the tag the class "no-color". Only if jacascript is activated the class no-color is removed and the text shall be colorized. My current css is not working. Here a sample code. I don't need a solution that adds a class to the p-tag because this is just a sample code. js fiddle

SASS

:not(.no-color) {
p {

color: red;

}
}


HTML

<div class="no-color">
<p>hello world</p>
</div>

Answer

Just add div to your selector DEMO

div:not(.no-color) {
  p {
    color: red;
 }
}

Or in pure CSS that would be div:not(.no-color) p

div:not(.no-color) p {
  color: red;
}
<div class="no-color">
  <p>hello world</p>
</div>
<div>
  <p>hello world</p>
</div>