jQuery change media query width value

2019-04-24 14:38发布

问题:

Is it possible with jQuery or anything else to change width value of @media query css while page is running?

So for example if in style.css I've got

@media screen and (min-width: 400px) {
   /*whatever*/
}

to change it to 500px after website is loaded

回答1:

This is not possible through traditional method. You have to insert the full css through jQuery. For e.g :

 $('body').append("<style type='text/css'>@media screen and (min-width: 500px) { /*whatever*/ }</style>");