D
D
Dima2021-02-07 19:05:40
css
Dima, 2021-02-07 19:05:40

How to write a media query to a variable in Stylus?

I can't find an explanation in the documentation. I have a media query I want to put it in a variable using a quote character:
(min-width: 320px) and (max-width: 768px)

mobile

mobile = '(min-width: 320px) and (max-width: 768px)'


To end up like this:
@media mobile
  .class
    width 100%


But doesn't work. without quotes also does not work, what is the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-02-07
@qpz

Only with crutches.
https://stackoverflow.com/questions/13060726/varia...

t = 1000px

unquote("@media screen and (max-width: " + t + ") {")
html
    background blue
unquote("}")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question