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);
}
<divclass="test">BASE</div><divclass="container"><divclass="test">BASE</div></div>

Post a Comment for "Css Selector To Exclude All Children Where Any Parent At Any Level Has A Class"