什么是“iPhone 视口比例错误”?

发布于 2024-12-19 12:32:26 字数 922 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢望 2024-12-26 12:32:26

使用 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文