0

I have a specific question about SASS and how to make conditional styling from outside a nesting.

Given I have following case:

.wrapper {
  .child {
    @at-root .wrapper {
      background: red;
    }
  }
}

so what I'm trying to do is, that .wrapper only gets a background: red if .child is existing. I know there is nothing like a parent selector in CSS, but maybe there is somehow a way to achieve this.

supersize
  • 10,844
  • 14
  • 56
  • 108
  • Sass is nothing more than syntactic sugar for CSS. If it is not possible with CSS, then it simply isn't possible with Sass either, as at the end of the day, this is hinged on the existence of a parent selector. – BoltClock Jun 19 '15 at 08:54
  • @BoltClock I already pressumed that, but maybe there is some kind of logic I miss. There is plenty of other preprocessing magic, thats why I thought to ask. – supersize Jun 19 '15 at 08:56
  • What sort of magic exactly? – BoltClock Jun 19 '15 at 08:56
  • @BoltClock variable interpolation or so, which is functional wise "magic" compared to plain CSS. But I know what you are trying to say. Maybe there is a SASS function way to achieve the OP. – supersize Jun 19 '15 at 08:58

0 Answers0