从我的经验来看,Media Queries在PhoneGap中的工作非常糟糕。例如当PhoneGap的设置,你在你的index.html页面如下:
<link media="only screen and (max-device-width: 480px)" href="css/iphone.css" type="text/css" rel="stylesheet" />
<link media="only screen and (max-device-width: 1024px)" href="css/ipad.css" type="text/css" rel="stylesheet" />
我无法得到它的工作无论我如何改变了一些事情,我最后不得不使用条件CSS来添加以下javascript:
loadDeviceStyle: function() {
$("head").append("<link>");
css = $("head").children(":last");
css.attr({
rel: "stylesheet",
type: "text/css",
href: 'css/' + Utils.device() + '.css'
});
}
这显然不够理想。我还发现viewport
设置是一个主要的麻烦,不得不围绕它编码。虽然这可能是我的错误,但文档并没有帮助我清理问题,所以请准备花时间在这个问题上。
说了这么多 - 因为PhoneGap很容易设置,所以我会试着为你想要做的事情创建一个概念证明。你花时间回答这个问题肯定会减少头痛。
我结束了使用“ExternalScreen”插件,我告诉它加载什么HTML。我用它自己的样式表加载了一个'单独的'html文件。在JS获得它之前,基本上按照你所说的去做。 – andrewpthorp
很好找。对于其他人来说,ExternalScreen的网址是:https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/ExternalScreen –