I am trying to apply a style to a div based on its parent class. I am using the :not() selector to select the div whose parent is not .container1
, the second di
You're selecting wrong elements. No reverse lookups possible, see here:
div:not(.container1) > .myDiv {
color: red;
}
Div 1
Div 2
Ideally, you'd group those parent divs under the same class in order to avoid the super-generic div
selector:
.container:not(.container1) > .myDiv {
color: red;
}
Div 1
Div 2