1

any body know if it's possible to pass value global from :root file to other css file for @media operation. I've the feeling is not possible. If it's possible, how ? If it's not possible, why ?

my idea is do that

global css file loaded at first

:root {
 --value: 200px;
 --my-height:20px;
}

other css file

@media(min-width : var(--value)) {
 .my_class {
   height: var(--my-height);

}
Knupel
  • 323
  • 2
  • 14
  • 3
    According to this answer: https://stackoverflow.com/a/40723269/9288348 it is not possible. However it is possible to rewrite your ```:root{...}``` variables inside your @media – Jeremy Dec 22 '22 at 15:09
  • 2
    a good resource about that: https://bholmes.dev/blog/alternative-to-css-variable-media-queries/ – rocambille Dec 22 '22 at 15:10
  • The variables can be read in the second file but "you just cannot use them in a media query declaration" – Cédric Dec 22 '22 at 15:15

0 Answers0