postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
415 stars 36 forks source link

cant change variables in @media query #119

Closed ksawery29 closed 1 year ago

ksawery29 commented 1 year ago

Hi, I'm trying to change $width variable in media query when the screen size is 500px, but it isn't changing. Here's my code:

$width: 200px;

div {
  width: $width;
}

@media (min-width: 500px) {
  $width: 100px;
}

It's worth adding that I can change variables in other elements like this:

div {
  $width: 100px;
  width: $width;
}
ai commented 1 year ago

This variables doesn’t work like this. You need to use CSS Custom Properties for this feature.

ksawery29 commented 1 year ago

oh yeah I didn't think about it, thanks