Reputation: 3000
I have the following scss snippet. When .child
is present I want the .container
to have a color of yellow
I have code elsewhere which removes adds/removes the element with .child
on it
.container {
height: 100%;
color: red;
:global {
.child {
background-color: black;
}
.container .child { <=== This obviously doesn't work but
I need .container to be yellow only when child is present
color: yellow;
}
}
}
How do I represent that in scss?
Upvotes: 1
Views: 1383
Reputation: 6129
Even though you're using SCSS, we still can't get around the fact that There is currently no way to select the parent of an element in CSS. In your code that add/removes the element with the child
class, add an additional class to the parent container
so that you can color it.
Upvotes: 2