csssassweb-compiler

Stop SASS from compiling out trailing spaces in CSS


I am trying to target IE 8 & 9 via a browser specific CSS hack as demonstrated here. However, I am using SASS, (in particular, the WebCompiler Visual Studio extension), and it compiles out the trailing spaces before the semicolon. Thus

.class{ display: none \ ;}

becomes

.class { display: none \;}

and breaks the hack. Is there any way to work around this?


Solution

  • If you need a space you can concatenate an empty string.

    SASS:

    .class{ display: none \ +'';}
    

    Output:

    .class {
      display: none \ ;
    }