Marc Blase

Negative value for margin using calc() in SCSS

Using SCSS and need to set a negative margin with calc on an interpolated variable. Here’s the solution:

.container {
  margin-top: calc((#{$VAR_NAME} + 0px)/-1); // divide by -1 to get a negative result
}
Published on November 18, 2019