我正在使用 AppMobi XDK 并想根据屏幕分辨率在不同设备上应用一些样式。问题是我无法确定任何模拟设备的宽度和高度。请帮忙
问问题
1475 次
3 回答
2
您可以根据 window.innerHeight 和 window.innerWidth 获取大小。
XDK 中存在一个问题,即在触发 appMobi.device.ready 事件后 300 毫秒以上才可用。
于 2012-04-01T01:26:40.730 回答
0
问题是设备准备就绪时窗口高度不正确。这对我来说很好:
var onDeviceReady = 函数 () {
intel.xdk.device.setRotateOrientation("any");
intel.xdk.device.setAutoRotate(true);
setTimeout(setDisplayScreen, 300);
function setDisplayScreen() {
var dHeight = window.innerHeight;
$('body').css('height', dHeight)
intel.xdk.device.hideSplashScreen();
}
};
于 2014-09-16T11:10:52.287 回答
0
根据 Ian 的评论,appMobi.device.ready 被触发后需要 300 毫秒。
在您的 index.html 文件中,只需在 onDeviceReady 函数中添加一个 setTimeout 即可。
var onDeviceReady=function(){
//Size the display to 768px by 1024px
// AppMobi.display.useViewport(768,1024);
//hide splash screen
AppMobi.device.hideSplashScreen();
setTimeout(setDisplayScreen, 300);
};
在我的情况下,我只想在屏幕底部有页脚,我已经在 PX 中设置了它。
function setDisplayScreen(){
var dHeight = window.innerHeight;
document.getElementById("footer").style.top = dHeight - 70 + "px";
}
它工作得很好。在页脚出现之前有一个小的延迟,但这还不错。
于 2013-04-05T22:13:54.770 回答