0

At runtime I will know the client phone's network and so on, but how can I change the background-image css property?

Because of the compatibility,I cannot use the service worker to intercept the request.

Media queries are not suitable because there are too many options.

Can I use css vars or calc to solve this problem?

:root {
    --post-fix: '@q_80'

    --url:'http://imgdoc.bce.baidu.com/bce-documentation/BOS/image.jpg'var(--post-fix)
}
Shadow
  • 8,749
  • 4
  • 47
  • 57
  • Please, format your question. – Jeroen Heier Apr 16 '18 at 03:52
  • No, you can't concatenate strings with css variables, what you can do though is to edit this url variable altogether from js (note that it would have to include the `url(` part as well) , or even just set a class from js and different values according to each class. – Kaiido Apr 16 '18 at 04:27

0 Answers0