1

I have the following:

div {
   .demo {
      color: #000;
   }
}

Which Outputs:

div .demo { color: #000; }

However, I need it to output without the space between the element and the class:

div.demo { color: #000; }

Is there any way to do this using SASS Nesting?

Ry-
  • 218,210
  • 55
  • 464
  • 476
Blanky
  • 251
  • 1
  • 3
  • 15

2 Answers2

4

Use & to combine a selector with its parent:

div {
   &.demo {
      color: #000;
   }
}
Ry-
  • 218,210
  • 55
  • 464
  • 476
2

You can use the ampersand in front of .demo to achieve this.

div {
   &.demo {
       color: #000;
   }
}

The ampersand character is a placeholder for whatever the parent element is.