Is it possible to style parents of a certain type of element in SASS?

I want to do this:

.classname {
  color: red

  a& {
    color: blue;
  }
}

and for compilation:

.classname {
   color: red;
}

a.classname {
   color: blue;
}

Is there any syntax to support this? I tried to use a&, #{a&}and the compass function #{append-selector("a", "&")}, but they do not compile, a &does, but the results are obviously in a .classname, and not a.classname.

+5
source share
3 answers

This cannot be done with the nested syntax for SASS. From SASS help :

An internal rule applies only to the external rule selector.

- , CSS , CSS. , , ( ) .

-1

, , ""? - , , , .

0

, &[href]. , ( <a> .)

Soon we will be able to use &:any-link( what is the any-link pseudo-class for? ), But it is not yet supported by browsers

0
source

All Articles