Generating CSS media queries with javascript or jQuery

后端 未结 3 1771
再見小時候
再見小時候 2020-12-08 03:24

Is it possible to create full media query rules on the fly using Javascript or jQuery?

I\'ve used numerous media queries to target generalised viewports and spec

3条回答
  •  悲&欢浪女
    2020-12-08 03:59

    I use this way. This allows to update multiply styles in document

    in HTML:

    
    

    in JS

    $(".background_image_styles").text("@media (min-width: 1200px) {.user_background_image{background-image: url('https://placehold.it/1200x300');}}");
    

提交回复
热议问题