0

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?

Decrypter
  • 2,784
  • 12
  • 38
  • 57
  • 2
    Possible duplicate of [Is there a CSS parent selector?](https://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – Quentin Oct 01 '17 at 21:42

1 Answers1

2

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.

Sam Rueby
  • 5,914
  • 6
  • 36
  • 52