【发布时间】:2014-02-24 05:06:10
【问题描述】:
基本上我要做的是让我的视口宽度在所有移动浏览器上都相同,并确保用户无法放大或缩小(缩放)。
似乎没有正确支持此功能的移动浏览器是:
- Windows 手机 8 IE10
- Android 原生浏览器
- 安卓火狐浏览器
以下代码行适用于所有移动浏览器,除了来自公司的那种像往常一样拒绝标准的公司(IE,在本例中为 IE10 Mobile):
<meta name="viewport" content="width=620, user-scalable=no" />
我发现这个问题的答案已被接受:
Viewport for IE10 & 11 desktop, but not mobile
应用下面的 css 和 javascript 代码后,它仍然将视口保持为设备宽度,而不是我试图实现的 620。
CSS:
@-webkit-viewport { width: 620; }
@-moz-viewport { width: 620; }
@-ms-viewport { width: 620; }
@-o-viewport { width: 620; }
@viewport { width: 620; }
Javascript:
$(function(){
if (navigator.userAgent.match(/IEMobile\/10\.0/) || navigator.userAgent.match(/IEMobile\/11\.0/)) {
var msViewportStyle = document.createElement("style")
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
)
document.getElementsByTagName("head")[0].appendChild(msViewportStyle)
}
alert($(window).width());
});
【问题讨论】:
-
顺便说一下,user-scalable=no 也会被忽略
标签: android html web-applications windows-phone-8 viewport