489

I've written this code, but it does not work. What is my problem?

.class {
    margin:20px;
    :hover {
        color:yellow;
    }
 }
cimmanon
  • 67,211
  • 17
  • 165
  • 171
Beach Boys
  • 5,029
  • 2
  • 14
  • 7

2 Answers2

1101

For concatenating selectors together when nesting, you need to use the parent selector (&):

.class {
    margin:20px;
    &:hover {
        color:yellow;
    }
}
Sinac
  • 11,374
  • 2
  • 17
  • 23
66

You can easily debug such things when you go through the generated CSS. In this case the pseudo-selector after conversion has to be attached to the class. Which is not the case. Use "&".

http://sass-lang.com/documentation/file.SASS_REFERENCE.html#parent-selector

.class {
    margin:20px;
    &:hover {
        color:yellow;
    }
}
Enrico Stahn
  • 2,967
  • 1
  • 23
  • 23