question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

compile error: percent after interpolation

See original GitHub issue

sass-4.2.0: bug:

$pcs: map-get($settings, "percent");
@each $pc in $pcs {
  .w-#{$pc}pc {
    width: #{$pc}%
  }
}

work well:

@each $pc in $pcs {
  .w-#{$pc}pc {
    width: #{$pc}px or any other css units
  }
}

Error: Invalid CSS after \"...width: (#{$pc}%\": expected expression (e.g. 1px, bold), was \")\"\A

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
fvignalscommented, Sep 29, 2017

Thx so much, I tried lot of things but I forgot function. So, for next readers:

$settings: ( percent: (10, 20, 25, 50, 75, 80, 100) ); 
$pcs: map-get($settings, "percent");
@each $pc in $pcs {
  .w-#{$pc}pc {
    width: percentage($pc/100);
  }
}

output:

.h-10pc { height: 10%; }
.h-100pc { height: 100%; }
0reactions
nex3commented, Jun 13, 2022

@b-d-k From the Sass documentation:

⚠️ Heads up!

It’s almost always a bad idea to use interpolation with numbers. Interpolation returns unquoted strings that can’t be used for any further math, and it avoids Sass’s built-in safeguards to ensure that units are used correctly.

Sass has powerful unit arithmetic that you can use instead. For example, instead of writing #{$width}px, write $width * 1px—or better yet, declare the $width variable in terms of px to begin with. That way if $width already has units, you’ll get a nice error message instead of compiling bogus CSS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SCSS interpolation error, trying to concatenate a percentage ...
node. js - SCSS interpolation error, trying to concatenate a percentage sign after a variable in a loop - Stack Overflow. Stack Overflow...
Read more >
What is the correct way to combine data points with error?
Thinking about the linear interpolation, my understanding is it averages the error from the two closest points, ignoring the error of all other ......
Read more >
Finding the percentage error - YouTube
This video screencast was created with Doceri on an iPad. Doceri is free in the iTunes app store. Learn more at http://www.doceri.com.
Read more >
Using cross validation to assess interpolation results
Cross validation is performed automatically while building an interpolation model, and results are shown on the last page of the Geostatistical Wizard.
Read more >
Incorrect "unexpected term" error when using variable ...
Attempt to use scss variable interpolation to define operation in calc() expression results into "unexpected term" error while sass compiler produces ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found