【问题标题】:ionic2 - ion-card with background imageionic2 - 带背景图像的离子卡
【发布时间】:2018-08-15 15:34:40
【问题描述】:

我想了解this ion-card background image 的工作原理。他们的html 是这样的:

<ion-content class="card-background-page">

  <ion-card>
    <img src="img/card-saopaolo.png"/>
    <div class="card-title">São Paulo</div>
    <div class="card-subtitle">41 Listings</div>
  </ion-card>
...

然后设置sass:

.card-background-page {

  ion-card {
    position: relative;
    text-align: center;
  }

  .card-title {
    position: absolute;
    top: 36%;
    font-size: 2.0em;
    width: 100%;
    font-weight: bold;
    color: #fff;
  }

  .card-subtitle {
    font-size: 1.0em;
    position: absolute;
    top: 52%;
    width: 100%;
    color: #fff;
  }

}

没有z-index&lt;img src="img/card-saopaolo.png"/&gt;怎么会神奇地变成背景呢?是sass 处理的东西吗?还是我以前从未学过的其他东西?

【问题讨论】:

    标签: html css ionic2


    【解决方案1】:

    card-titlecard-subtitle 只是简单地放在带有position: absolute 的图像顶部,不需要z-index

    【讨论】:

      【解决方案2】:

      岩石 寒岩 摇滚之寒 恍惚效果

      1 歌曲

      .headerWelcomeTile {
        margin: 0px 0px 0px 0px !important;
        width: 100% !important;
        height: 35%;
        position: relative;
        text-align: center;
      }
      
      .headerWelcomeTileSub {
        margin: 30px 35px 0px 20px;
        background: black !important;
      }
      
      .headerSubDiv {
        position: absolute;
        margin: 0px 0px 0px 15px !important;
        height: 70%;
        position: relative;
        text-align: center;
        width: 75%;
      }
      <ion-card class="cardBackColor card card-md headerWelcomeTile">
          <div style="height: 20%;">
              <img class="imag-height" src="https://trunkitmusic.com/assets/music/RM/PRG/The%20Family%20Cheese/The%20Family%20Cheese%20LP/album.jpg">
          </div>
          <ion-card-content class="cardSubBackColor card-content card-content-md headerSubDiv " text-wrap="">
              <ion-row class="row">
                  <ion-col class="col" col-4="">
                      <img style="height: 80px;width: 80px;" src="https://trunkitmusic.com/assets/music/PP/IND/Trance Effect/artist.jpg">
                  </ion-col>
                  <ion-col class="col">
                      <ion-segment class="segment segment-ios ng-untouched ng-pristine ng-valid segment-md">
                          <ion-segment-button aria-pressed="true" class="segment-button segment-button" role="button" tappable="" value="Paid">
                              Rock
                              <div class="button-effect"></div>
                              <div class="button-effect"></div>
                          </ion-segment-button>
                          <ion-segment-button aria-pressed="false" class="segment-button segment-button" role="button" tappable="" value="Free">
                              Chill Rock
                              <div class="button-effect"></div>
                              <div class="button-effect"></div>
                          </ion-segment-button>
                          <ion-segment-button aria-pressed="false" class="segment-button segment-button" role="button" tappable="" value="Top">
                              Rock Chill
                              <div class="button-effect"></div>
                              <div class="button-effect"></div>
                          </ion-segment-button>
                      </ion-segment>
                      <div class="artisName">
                          <img src="assets/img/user-music.png" style="width:10px;">
                          <p class="small-text white uperSpaceArtisName">Trance Effect</p>
                      </div>
                      <p class="very-small-text lightGrey">1 Songs</p>
                  </ion-col>
              </ion-row>
              <!--template bindings={}-->
          </ion-card-content>
      </ion-card>

      【讨论】:

      • 您能否解释一下这如何解决 OP 的问题?单独的代码块并不能提供那么多信息......
      • 你需要管理 DIV 和 ,确保你的图像 div 先设置然后你必须添加你的
      猜你喜欢
      • 1970-01-01
      • 2016-07-11
      • 1970-01-01
      • 2021-01-13
      • 1970-01-01
      • 1970-01-01
      • 2019-01-24
      • 2019-11-06
      • 1970-01-01
      相关资源
      最近更新 更多