8000 calc() algebra · Issue #10 · xem/miniMinifier · GitHub
[go: up one dir, main page]

Skip to content

calc() algebra #10

Open
Open

Description

@tomhodgins
div {
  background: lime;
  width: calc((100px - 1em) + (-50px + 1em));
  height: calc((100px - 1em) + (-50px + 1em));
}

correct minification

div{background:lime;width:50px;height:50px}
  • even without evaluating units we can still use algebra and simplify this formula down to 50px by eliminating things that cancel out

CSSnano output

div{background:lime;width:calc((100px - 1em) + (-50px + 1em));height:calc((100px - 1em) + (-50px + 1em))}
  • in this situation - 1em and + 1em cancel each other out
  • next calc((100px) + (-50px)) can be further simplified as calc(100px - 50px)
  • this can be evaluated to 50px

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0