A
A
Alianos2021-05-10 01:32:00
Sass
Alianos, 2021-05-10 01:32:00

How to use scss variable in calc?

Hello, please tell me why this code does not compile correctly

div {
  $item-margin: 1vmin;
  width: calc(50vw - $item-margin * 2);
  height: calc(50vw - $item-margin * 2);
  background: red;
}

output only
div {
  width: calc(50vw - $item-margin * 2);
  height: calc(50vw - $item-margin * 2);
  background: red;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei Nazarenko, 2021-05-10
@Alianos

div {
  $item-margin: 1vmin;
  width: calc(50vw - #{$item-margin} * 2);
  height: calc(50vw - #{$item-margin} * 2);
  background: red;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question