A
A
Alianos2021-05-08 18:04:53
Sass
Alianos, 2021-05-08 18:04:53

Why is @media not copied to css?

Hello, please tell me why this code is not working

<!DOCTYPE html>

<body>
  <div class="frame"></div>
</body>

</html>

.frame {
  @mixin superVar($var, $number, $vh, $vw) {
    @media (min-aspect-ratio: 2/1) {
      $var: $number * $vh;
    }
    @media (max-aspect-ratio: 2/1) {
      $var: $number * $vw;
    }
  }
  @include superVar("--superVmin", 1, 2, 1);
  width: calc(10 * var(--superVmin));
  height: 10vmin;
  background: red;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ankhena, 2021-05-09
@Alianos

@mixin superVar($var, $number, $vh, $vw) {
  @media (min-aspect-ratio: 2/1) {
    #{$var}: $number * $vh;
  }
  @media (max-aspect-ratio: 2/1) {
    #{$var}: $number * $vw;
  }
}
.frame {
  @include superVar(--superVmin, 1, 2vh, 1vw);
  width: calc(10 * var(--superVmin));
  height: 10vmin;
  background: red;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question