css - 图像未显示在设备上(Ionic2 应用程序)

标签 css image ionic2 device serve

我正在 Ionic2 中开发一个应用程序。行的背景中有一张图片。我还在行中放置了一张图片。图像在浏览器上看起来很好( ionic 服务)。但是,只有背景图像显示在一个真正的移动设备。会是什么原因。 enter image description here enter image description here

home.html

<ion-grid> 
       <ion-row class="menurow">
           <ion-col class="img2">
              <img src="../assets/images/noun_683380_cc.png">
              <h4 class="text text-center">OUR SERVICIES</h4>
           </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img3">
              <img src="../assets/images/news.png">
              <h4 class="text text-center">REFERENCES</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img4">
               <img src="../assets/images/photo.png">
               <h4 class="text text-center">PHOTOS</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img5">
              <img src="../assets/images/video.png">
              <h4 class="text text-center">VIDEOS</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img6">
              <img src="../assets/images/contact.png">
              <h4 class="text text-center">CONTACT</h4>
          </ion-col>
        </ion-row>

</ion-grid>

home.scss

  .img2{
   background-size: contain;
   text-align: center;
   background-image: url("../assets/images/photo-1471341971476-
   ae15ff5dd4ea.png"),

  }
 .img2 img{
  position: relative;
  top:8px;
  width: 14%;

 }

 .img3{
 background-size: contain;
 text-align: center;
 background-image: url("../assets/images/ross-sokolovski-115060.png") ;
 }

 .img3 img{
  position: relative;
  top:8px;
  width: 14%;
}

.img4{
  background-size: contain;
 text-align: center;
 background-image: url("../assets/images/aron-visser-212265.png") ;
}
.img4 img{
position: relative;
top:8px;
width: 14%;
}

.img5{
 background-size: contain;
 text-align: center;
 background-image: url("../assets/images/jakob-owens-96968.png") ; 
}
 .img5 img{
   position: relative;
  top:8px;
  width: 14%;
 }

.img6{
  background-size: contain;
  text-align: center;
  background-image: url("../assets/images/d-ng-tr-n-qu-c-104959.png") ;
 }
 .img6 img{
   position: relative;
   top:8px;
   width: 14%;
}

.menurow{
 padding: 5px;
}

最佳答案

在您的 html 中,您的相对路径不正确。

html 中的每个 Assets 都从路径中检索:'./assets/' 所以你的文件看起来像:

<ion-grid> 
       <ion-row class="menurow">
           <ion-col class="img2">
              <img src="./assets/images/noun_683380_cc.png">
              <h4 class="text text-center">OUR SERVICIES</h4>
           </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img3">
              <img src="./assets/images/news.png">
              <h4 class="text text-center">REFERENCES</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img4">
               <img src="./assets/images/photo.png">
               <h4 class="text text-center">PHOTOS</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img5">
              <img src="./assets/images/video.png">
              <h4 class="text text-center">VIDEOS</h4>
          </ion-col>
        </ion-row>
        <ion-row class="menurow">
          <ion-col class="img6">
              <img src="./assets/images/contact.png">
              <h4 class="text text-center">CONTACT</h4>
          </ion-col>
        </ion-row>

</ion-grid>

关于css - 图像未显示在设备上(Ionic2 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43820221/

相关文章:

jquery - 图片 :hover doesn't works with background-color

css - Bootstrap navbar navbar-fixed-top 在一定尺寸后崩溃

php - Float left 在 Drupal 表单中无法正常工作

c++ - image.convertTo 并不总是有效

angular - 如何在 ionic 2 和 Angular 2 上使用 http post 方法?

typescript - Ionic 2修改Index.html

html - 如何进行以下更改(表格元素样式)

javascript - 防止在网页上缓存图像

html - 如何使用 'aside' 标签使垂直图像居中?

css - ionic 行渲染出屏幕