jQuery更改媒体查询宽度值 [英] jQuery change media query width value
本文介绍了jQuery更改媒体查询宽度值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在页面运行时,是否可以使用jQuery
或其他任何方式更改@media query
css
的宽度值?
Is it possible with jQuery
or anything else to change width value of @media query
css
while page is running?
例如,如果我在style.css中拥有
So for example if in style.css I've got
@media screen and (min-width: 400px) {
/*whatever*/
}
在网站加载后将其更改为500px
to change it to 500px
after website is loaded
推荐答案
这是通过传统方法无法实现的.您必须通过jQuery插入完整的CSS.例如:
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>");
这篇关于jQuery更改媒体查询宽度值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文