首先我有这个媒体查询
@media screen and (min-width: 1000px) {
activate style A
}
它找到了应有的效果。(我的iphone 6不会激活样式A)
然后我有这个功能来在页面加载时改变视口设置:
function changeViewportMeta() {
var x = document.querySelector('meta[name="viewport"]')
if (screen.width < 320){
x.setAttribute("content", "width=device-width,initial-scale=0.59");
} else if(screen.width < 380){
x.setAttribute("content", "width=device-width,initial-scale=0.63");
}else if(screen.width < 430){
x.setAttribute("content", "width=device-width,initial-scale=0.70");
}else if(screen.width < 650){
x.setAttribute("content", "width=device-width,initial-scale=0.80");
}else if(screen.width <750){
x.setAttribute("content", "width=device-width,initial-scale=0.90");
}else if(screen.width >=750){
x.setAttribute("content", "width=device-width,initial-scale=1.0");
}
}
我&#34;绑定&#34; <body onload="changeViewportMeta()">
在此之后,似乎媒体查询不再能够正常运行。现在,如果我使用我的Iphone横向视图,我可以激活样式A.它有点好,但不是我预期的。如何解决这个问题?