In Sass, How do you reference the parent selector and exclude any grandparent?

sass

Solution

There's no way I know of in SASS to pick and choose from ancestor selectors when using a parent reference. With your code, though, a little reorganization can get you the same result:

label {
    .class & {
        color: #fff;
    }

    .disabled & {
        color:#333;
    }
}

Compiles to:

.class label {
  color: #fff; }
.disabled label {
  color: #333; }

Problem

I have the following sass code: ``` .class{ label{ color:#fff; .disabled &{color:#333; } } } ``` which outputs ``` .disabled .class label ``` Is there a way to output the parent selector without any grandparent selectors being included? Like so: ``` .disabled label ```

Original source

Related problems