【问题标题】:Use one big image for background or multiple ones in Cordova?在 Cordova 中使用一张大图作为背景还是使用多张大图?
【发布时间】:2016-08-11 13:30:53
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: android ios css cordova hybrid-mobile-app


    【解决方案1】:

    我建议使用 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>
    

    【讨论】:

      【解决方案2】:

      你有办法将该图像用作图案吗?这样做您不会遇到不同屏幕尺寸的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-02
        • 2016-09-07
        • 2018-12-03
        • 2012-11-28
        • 1970-01-01
        • 2013-09-25
        • 1970-01-01
        相关资源
        最近更新 更多