为什么背景图片不显示?

why background image not display?

我正在尝试制作简单的应用程序单页应用程序。实际上我拍摄的背景图片放在 上,它在我使用 <ion-content class="bg" style="position:absolute!important"> 时显示position:absolute 但它显示在小区域。我需要在整个竞争中显示。换句话说在整个竞争标签完整屏幕中。 这是我的代码

http://codepen.io/anon/pen/pvYdNM

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic List Directive</title>

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
  </head>

  <body >
        <ion-view>
      <ion-header-bar class=" bar bar-positive ">
      <h1 class="title">Title!</h1>    

      </ion-header-bar>
      <ion-content class="bg"  style="position:absolute!important">
          <h1 >contend</h1>
          </ion-content>
          <ion-footer-bar class=" bar bar-footer bar-positive" style="position:fixed!important">
           <h1 class="title">Fotter!</h1>
          </ion-footer-bar>
      </ion-view>



  </body>
</html>

因为您的内容有一个 bg class,它没有覆盖您的所有页面。您设置的是 bg class 的背景,而不是 body 的背景。你应该这样做:http://codepen.io/anon/pen/pvYpVw

body 
{background: url('https://d262ilb51hltx0.cloudfront.net/max/800/1*AJALCafqXhfLMG7iF7Ho0A.jpeg')!important;}

您应该为 class bg 更新 css 规则。 最简单的方法是添加: top:0; left:0; right:0; bottom:0; 到背景 class.

只要告诉它应该有多大就可以了。

类似于:

<ion-content class="bg"  style="position:absolute; left: 0; right: 0; top: 43px; bottom: 43px;">

应该可以。

您只需添加

height: 100%;
width: 100%;

您的 .bg css 规则