【问题标题】:iPhone 4 web-app browser width: 960 or 981?iPhone 4 网络应用浏览器宽度:960 还是 981?
【发布时间】:2011-10-30 17:33:32
【问题描述】:
<html>
    <body REMonload="document.location.assign('index2.php?w=' + window.innerWidth + '&h=' + window.innerHeight);">
    <script language="javascript">
    document.write('w=' + window.innerWidth + '&h=' + window.innerHeight);
    </script>
    </body>
</html>

输出:

w=981&h=425

为什么?维基百科说,w 应该是 960。

问候,

更新

我发现,问题与 viewport 元标记有关。

下面的代码做了我想看到的:

<html style="width:100%; height:100%;">
<head>
<meta name="viewport" content="width=device-width; initial-scale=0.5; minimum-scale=0.5; maximum-scale=0.5; user-scalable=no;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
    <body style="width:100%; height:100%; background-color: blue;"
    REMonload="document.location.assign('index2.php?w=' + window.innerWidth + '&h=' + window.innerHeight);"
    onload="alert('w=' + window.innerWidth + '&h=' + window.innerHeight);">
    </body>
</html>

看看这个元数据:

name="viewport" content="width=device-width; initial-scale=0.5; minimum-scale=0.5; maximum-scale=0.5; user-scalable=no;"

我不明白,它是如何工作的。我已经尝试过设备宽度的系数 1.0(我想是 960),但似乎我需要的是 0.5。

无论如何,它适用于我的 iPod Touch 4 (960*640)。

您能否在 iPad 或 iPad2 和 iPhone/iPod Touch 1 或 2 或 3 上尝试该代码?是对应的1024/768和480/320吗?换句话说,我可以对任何 Apple 设备使用相同的解决方案吗?

提前致谢!

【问题讨论】:

    标签: web-applications width iphone-4


    【解决方案1】:

    iPhone 3GS:
    1.横向:w=960 h=416
    2.人像:w=640 h=712

    iPhone 4:
    1.横向:w=960 h=416
    2.人像:w=640 h=712

    iPad 1
    1.横向:w=2048 h=1344
    2.人像:w=1536 h=1856

    iPad 2
    1.横向:w=2048 h=1344
    2.人像:w=1536 h=1856

    编辑:添加 3GS 数据
    edit2:添加了 ipad2 数据

    看看你和我的结果,我会说后来的 iPhone 和 iPod touch 看起来是一样的,而且两台 iPad 也很相似。

    【讨论】:

    • 非常感谢您提供的数据!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-29
    • 1970-01-01
    • 2011-01-11
    • 2012-04-12
    • 2012-10-30
    相关资源
    最近更新 更多