jQuery change media query width value

丶灬走出姿态 提交于 2019-12-22 04:33:29

问题


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>");


来源:https://stackoverflow.com/questions/17147532/jquery-change-media-query-width-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!