[英]Background image sizes for diferente mobile devices with Phongap
I am developing an app for iOS and Android using Phonegap. 我正在使用Phonegap开发适用于iOS和Android的应用程序。
I want to use a background-image but since all mobile devices have different sizes my background image gets either cut or distorted. 我想使用背景图像,但是由于所有移动设备的尺寸都不同,所以我的背景图像被切割或扭曲了。
For the splash screen (which is also a fullscreen image) I can define different images for different devices 对于启动画面(也是全屏图像),我可以为不同的设备定义不同的图像
Is there something similar that I can do for my background-image? 我可以为背景图片做些类似的事情吗?
No, you can't do that with cordova configuration. 不,您无法使用cordova配置做到这一点。
But you can css and media query: 但是您可以通过CSS和媒体查询:
#my-app-container {
@media screen and (max-width: 320) {
background-image('/iphone4s-background.jpg');
}
@media screen and (max-width: 420) {
background-image('/bigger-background.jpg');
}
/* others */
}
Another way (but not better from my point of view) is to detect window size in js , changing then the background image from code (eg with jquery). 另一种方法(但从我的角度来看不是更好)是检测js中的窗口大小 ,然后从代码中更改背景图像(例如,使用jquery)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.