Sass Invalid CSS: expected expression (e.g. 1px, bold), was "{"

16,486

Your code is actually SCSS, not SASS.

To make it work as SASS, you need to get rid of curly braces, semi-colons and add some spaces.

Here's the corrected code:

@each $flag in USA, EUR, JPN 

  a.#{$flag} 
    display:inline-block
    overflow:hidden
    width: 0
    height: 11px
    padding-left: 16px
    background: url('http://res.cloudinary.com/mrengy/image/upload/v1470163121/#{$flag}.gif') no-repeat

https://codepen.io/vic3685/pen/akaEyo?editors=1100

Share:
16,486

Related videos on Youtube

Mike Eng
Author by

Mike Eng

User Experience Designer. mike-eng.com #SOreadytohelp

Updated on September 15, 2022

Comments

  • Mike Eng
    Mike Eng over 1 year

    I have the following Sass, following this example for @each:

    @each $flag in USA, EUR, JPN {
      a.#{$flag} {
        display:inline-block;
        overflow:hidden;
        width:0;
        height:11px;
        padding-left:16px; 
        background:url('http://res.cloudinary.com/mrengy/image/upload/v1470163121/#{$flag}.gif');
      }
    }
    

    It's just an example for an answer to another question. In CodePen, it is giving me an error:

    Invalid CSS after "USA, EUR, JPN ": expected expression (e.g. 1px, bold), was "{"

    Here's the example on CodePen.

    That error makes no sense. What is the problem here?

    • Victoria Ruiz
      Victoria Ruiz over 7 years
      I know very little SASS, but I know SCSS. If you change the compiler to SCSS, your code works. Maybe if you haven't been working on this long, that's a switch you can still do...
  • Mike Eng
    Mike Eng over 7 years
    Well, that's odd. I actually just changed the preprocessor in Codepen to use SCSS, and that resolved it as well.