我将我的第一个应用程序发布到“play store”并且是用 PhoneGap 制作的。
该应用程序在所有设备上看起来都不错,但在 Galaxy S3 和 Note II 中字体大小和 div 高度太大。
我有:
if (window.devicePixelRatio == 1.5) {
document.write('<link rel="stylesheet" type="text/css" href="css/hdpi.css">');
} else if (window.devicePixelRatio == 1) {
document.write('<link rel="stylesheet" type="text/css" href="css/mdpi.css">');
} else if (window.devicePixelRatio == 2) {
document.write('<link rel="stylesheet" type="text/css" href="css/xhdpi.css">');
} else if (window.devicePixelRatio == 0.75) {
document.write('<link rel="stylesheet" type="text/css" href="css/ldpi.css">');
}
加载正确的样式表。
银河 S3:
http://img17.imageshack.us/img17/7998/16761073.png
连结 4:
http://img802.imageshack.us/img802/2327/88668575.png
两个设备都是 720x1280。
最佳答案
Imo,最佳做法是在 css 中使用媒体查询来检测大屏幕。
通过媒体查询,您可以检测屏幕尺寸并对您的 css 进行适当的调整。
您可以通过执行 font-size : 100% 将字体大小重置为设备的默认字体大小
关于css - Phonegap + Galaxy s3 尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15899211/