【发布时间】:2015-07-08 13:05:59
【问题描述】:
我想问这个:
我有这款分辨率为 720 x 1280 像素的智能手机:
http://www.gsmarena.com/lenovo_p780-5544.php
但在 Cordova 应用程序中是以下代码 sn-p:
var width = $(window).width();
var height = $(window).height();
console.log("Screen size "+width+" " + height);
返回值 640 x 360 像素
这给设备(平板电脑与智能手机)的 CSS 样式优化带来了问题,因为如果我使用以下 CSS:
@media only screen
and (device-height: 720px)
and (device-width: 1280px)
and (-webkit-min-device-pixel-ratio: 1) {
#desk {
top:35%;
}
#menuRightSide {
top: 37%;
}
#castleHomePage{
top: 41%;
}
#spiderTwo {
width: 5.5%;
left:1%;
top:12%;
}
#movingSpiderOnTheNetWraper {
height: 25%;
top:1%;
}
#candle_1 {
bottom: 11%;
}
#candle_2 {
bottom: 10%;
}
#candle_4 {
bottom: 11%;
}
.candleFlame {
bottom: 46%;
}
}
在这种情况下,没有提到应用于屏幕的 css 规则。
元视口标签使用如下:
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
并且应用程序仅在横向模式下运行。
我想问一下,为什么javascript返回不同的值以及如何在Cordova + Ionic App上处理这个问题?
非常感谢您的任何建议。
【问题讨论】:
标签: javascript android css cordova