0

Why I can't use that code from LESS in SCSS:

.button, .input, .textarea {
  // some staff

  &_red {
    background: red;
    color: #fff;
  }
}

?

I need this CSS in output:

.button_red,
.input_red,
.textarea_red {
  background: red;
  color: #fff;
}

Prepros on compiling shows that error:

Syntax error: Invalid CSS after " &": expected "{", was "_red {" "_red" may only be used at the beginning of a compound selector. on line 4 of main.scss

cimmanon
  • 67,211
  • 17
  • 165
  • 171
A. Z.
  • 728
  • 1
  • 11
  • 28

2 Answers2

1

Your syntax is correct, however only for Sass 3.3 and up. Just tried this at SassMeister and it worked with Sass 3.3.4.

In the 3.2 versions this wasn't supported, see this Github issue for discussion on this.

Sidney Gijzen
  • 1,931
  • 3
  • 24
  • 27
0

You want this

https://stackoverflow.com/a/25655130/16940

Example:

            @at-root 
            {
                [barSize='large']#{&}
                {
                    font-size: 20px;
                }
            }
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689