android - 在 Cordova 中使用一张大图片作为背景还是多张图片?

标签 android ios css cordova hybrid-mobile-app

我正在为 iOS 和 Android 构建一个 Cordova 应用程序,因此自然会有很多不同的屏幕尺寸。

我的一些观点有完整的背景图片。我的问题是:

是使用一个覆盖最大潜在设备的大图像并仅将其用于所有设备,还是使用大量不同的图像并使用媒体查询将每个图像分配给正确的设备更好?

只是在这里寻找最佳实践。

最佳答案

我建议使用 2732 x 2048(今天最大的 iPad screen size)结合 cover 的图像、百分比或 viewport背景 css 调整大小。例如:

http://play.ionic.io/app/094f73be9047

CSS

ion-content {
  background-image: url(https://upload.wikimedia.org/wikipedia/commons/6/6c/Keeny-creek-wv-autumn-waterfall-scenery_-_West_Virginia_-_ForestWander.jpg);
  background-size: cover;

  text-align: center;
}

ion-content p {
  padding: 20px 0;
  color: white;
  font-weight: 100;
  font-size: xx-large;
}

html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <link href="https://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet">
    <script src="https://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>
  </head>
  <body ng-app="app">
    <ion-pane>
      <ion-header-bar class="bar-positive" class="bar-stable">
        <h1 class="title">Awesome App</h1>
      </ion-header-bar>

      <ion-content class="padding">
        <p>I am so beautiful</p>
        <button class="button button-positive">I'm a button</button>
      </ion-content>

    </ion-pane>
  </body>
</html>

关于android - 在 Cordova 中使用一张大图片作为背景还是多张图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38897810/

相关文章:

android - 无法在不更改其大小的情况下定位 RelativeLayout View 的子项

android - 如何将我的应用程序从 Eclipse 加载到我的 Android 手机而不是 AVD

ios - 升级到Beta iOS,然后再次降级有多安全?

ios - 从子 SKScene 中调用 Root ViewController 上的函数

android - Gradle 错误 : Write access is allowed from event dispatch thread only in Android Studio

javascript - jQuery.html() 在用 cordova 制作的 android 应用程序中不起作用

ios - UINavigationController忘记了自定义过渡动画后如何旋转子 Controller

css - Firefox 中输入字段之间的奇怪差距

javascript - 我需要做什么才能创建幻灯片

html - H1标签前后的额外空间