Skip to content Skip to sidebar Skip to footer

CSS Selector To Exclude All Children Where Any Parent At ANY LEVEL Has A Class

What I am trying to create a CSS selector which selects all children within a given parent; but excludes them as long as any element on the path has a certain class. Context I am c

Solution 1:

In modern browsers, you can use css variables.

Define it at root level, redefine it in your class:

:root {
    --mycolor: lightblue;
}

.container {
    --mycolor: lightgreen;
}

.test {
    background-color: var(--mycolor);
}
<div class="test">BASE</div>

<div class="container">
    <div class="test">BASE</div>
</div>

Post a Comment for "CSS Selector To Exclude All Children Where Any Parent At ANY LEVEL Has A Class"