简体   繁体   中英

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

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 (eg 1px, bold), was "{"

Here's the example on CodePen .

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

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

node-sass not working with new sass syntax. use npm i sass package!

3 hours of debugging... sass, thanks...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM