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.

This calc(-1 * var(--space-xl)); should be a negative value… but the -1 is ignored! The output is 3.25em but should be -3.25em.

CSS:

    --space-unit: 1em;
    --space-xl: calc(3.25 * var(--space-unit));

    .offset {
      top: inherit; 
      @include mq(md) {
        top: calc(-1 * 3.25em); // this works
        top: calc(-1 * var(--space-xl)); // don't work - should be negative
      }
    }

Gulp Task:

    .pipe($.postcss([
      /*
      Stylelint
      */
      $.stylelint(),
      /*
      Parse CSS and add vendor prefixes to rules by Can I Use
       */
      $.autoprefixer(),
      /*
      cssnano is a modern, modular compression tool written on top of the PostCSS ecosystem, which allows us to use a lot of powerful features in order to compact CSS appropriately.
       */
      $.cssnano({
        discardComments: {
          removeAll: true
        },
        discardDuplicates: true,
        discardEmpty: true,
        minifyFontValues: true,
        minifySelectors: true
      }),
      /*
      PostCSS-Custom-Properties lets you use Custom Properties in CSS, following the CSS Custom Properties specification.
      Example: h1 { color: var(--color); } <-- BECOMES --> h1 { color: red; color: var(--color); }
       */
      $.postcssCustomProperties(), // IE 11 polyfill
      /*
      PostCSS plugin to reduce calc()

      IE11 don't understand nested calc functions like this:
      margin-bottom: calc(calc(1.25*1em)*1)
      */
      $.postcssCalc(),
      /*
      PostCSS Error Reporter
      */
      $.postcssReporter({
        clearReportedMessages: true
      })
    ]))

Any ideas?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Jun 4, 2019

Please provide full css code, i can’t understand problem

0reactions
ludofischercommented, Jan 7, 2022

I cannot find a clear reproduction or even what the issue is. calc(-1 * var(--space-xl)) works correctly. The original issue does not seem related to nested variables, anyway https://github.com/postcss/postcss-calc/issues/91 is keeping track of that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Negative value - Wikipedia
Negative value may refer to: Negative predictive value in statistics; Negative ethic or philosophic value · Negative pricing · insolvency.
Read more >
Value-Positive, Value-Neutral, and Value-Negative
Value-Negative · Straight-Pitching · Excessive Rapport-Building · Poor Questions · Weak Discovery · Lack of Insight · Poor Follow-Through · Lack of ...
Read more >
Algebra Topics: Negative Numbers - GCFGlobal
A negative number is any number that is less than zero. For instance, -7 is a number that is seven less than 0....
Read more >
Intro to negative numbers (article) - Khan Academy
Negative numbers help us describe values less than zero. Example: When the temperature is ...
Read more >
Intro to negative numbers (video) - Khan Academy
Mysterious negative numbers ! What ARE they? They are numbers less than zero. If you understand the nature of below zero temperatures, you...
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