1

I want to use the & (which refers to a class) in combination with a tag. Like this example:

.back {
    text-transform: uppercase;
    text-decoration: none;
    font-weight: 700;
    color: blue;

    &:hover {
        color: red;
   }
}

I want only to use the hover for a-tags. The following is not possible

a&:hover {
     color: red;
}

Does anybody know this?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
sneeky
  • 1,458
  • 2
  • 13
  • 19
  • 3
    No, the `&` can't be used that way. The error you get when you try to use it that way says so: "&" may only be used at the beginning of a compound selector. – cimmanon Jan 10 '13 at 13:16
  • I've attempted to run the same thing they have in their documentation, but get the same error: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector – Chris Sep 03 '14 at 20:38

2 Answers2

0

If I understand your question correctly, you just don't need the &:

.back {
  ...

  a:hover {
    color: red;
 }

}

In sass, this will compile to .back a:hover { color:red; }. You don't need the &, as this is used to further extend the back class, which I don't think you want to do.

adamdport
  • 11,687
  • 14
  • 69
  • 91
-1
.back {
  ...
}

a.back:hover {
  color: red
}
zed_0xff
  • 32,417
  • 7
  • 53
  • 72