Skip to content

Nested calc with css variables #91

Closed
@kangw3n

Description

@kangw3n

thanks @evilebottnawi for redirection. #816

I'm encountering an issues while using calc() with CSS Custom variables where presets automatically remove my nested calc while custom variables is unable to resolve in build time.

Given that:

body {
  top: calc(100% - calc(10px + 10px));
}
/* will compile to*/
body {
  top: calc(100% - 20px);
}

when it comes to a css variables

body {
  top: calc(var(--pic-height) - calc(var(--width-height) + var(--border-gap)));
}
/* will compile to*/
body {
  top: calc(var(--pic-height) - var(--width-height) + var(--border-gap));
}

Capture

which is incorrect in mathematical stand points. To solve this problem, I end up by setting calc preset to false in plugin options.

Is there any possible to omit any clearing unintended nested calc while encountering css variable or if there is any better solution while dealing with variables value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bad-outputpostcss-calc produces incorrect outputbug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions