SASS Inherting parent class with in child selector

How does one select a parent class that the main div is set to .active and the child will inherit what the main div class is set to.

<div  class="myBox active">
  <div class="innerBox">
     <span>Some Text</span>
 </div>
</div>

then SASS

.myBox {
  .innerBox {
    span {
      color: red;
      .active {color: yellow;}
        }
    }
  }

I don’t do Sass so I may be wrong but looking at the documentation shouldn’t it be something like this:

.myBox {	
		span {
			color: red;
		}
   &.active span {
	color: yellow;
  }
}

The ampersand selects the parent.

Paul is correct. Right now your Sass is compiling to this (and you could have views the outputted CSS to confirm this)

.myBox .innerBox span .active{color: yellow;}

If you had put an & on there, it would have concatenated the selector into

.myBox .innerBox span.active{color: yellow;}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.