什么是“iPhone 视口比例错误”?
HTML5 移动样板 建议添加这段 Javascript 来修复“iPhone 视口比例错误”:
// Fix for iPhone viewport scale bug
// http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
MBP.viewportmeta = document.querySelector && document.querySelector('meta[name="viewport"]');
MBP.ua = navigator.userAgent;
MBP.scaleFix = function () {
if (MBP.viewportmeta && /iPhone|iPad|iPod/.test(MBP.ua) && !/Opera Mini/.test(MBP.ua)) {
MBP.viewportmeta.content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
document.addEventListener("gesturestart", MBP.gestureStart, false);
}
};
MBP.gestureStart = function () {
MBP.viewportmeta.content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
};
- 什么是“iPhone 视口”规模错误”? (链接的博客文章对我来说没有意义)
- 这段代码如何修复错误? (即,它到底有什么作用?)
HTML5 mobile boilerplate recommends adding this snippet of Javascript to fix the "iPhone viewport scale bug":
// Fix for iPhone viewport scale bug
// http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
MBP.viewportmeta = document.querySelector && document.querySelector('meta[name="viewport"]');
MBP.ua = navigator.userAgent;
MBP.scaleFix = function () {
if (MBP.viewportmeta && /iPhone|iPad|iPod/.test(MBP.ua) && !/Opera Mini/.test(MBP.ua)) {
MBP.viewportmeta.content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
document.addEventListener("gesturestart", MBP.gestureStart, false);
}
};
MBP.gestureStart = function () {
MBP.viewportmeta.content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
};
- What is the "iPhone viewport scale bug"? (The linked blog post doesn't make sense to me)
- How does this code go about fixing the bug? (I.e., what exactly does it do?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 iPhone 查看此演示页面。将手机从纵向旋转为横向。请注意,页面在横向视图上按比例放大。
请参阅此处了解详细信息 http://webdesignerwall.com/tutorials/iphone- safari-viewport-scaling-bug
也检查评论。
此屏幕截图也应该有帮助:
(来源:webdesignerwall.com< /a>)
View this demo page with an iPhone. Rotate the phone from portrait to landscape. Notice the page being scaled up on landscape view.
See here to know in Detail http://webdesignerwall.com/tutorials/iphone-safari-viewport-scaling-bug
check comments too.
This screenshot should help too:
(source: webdesignerwall.com)