1

我在使用ion-slides. 我正在使用这个 HTML 代码来创建一个简单的卡片:

<ion-header>
   <ion-navbar>
      <ion-title style="text-align:center;">Title</ion-title>
   </ion-navbar>
</ion-header>
<ion-content class="tutorial-page">

  <ion-card>
    <ion-card-content>
      <ion-card-title style="color:#000000;text-align:center;padding-top:10px; font-size: 24px; font-weight: bold;">
        Title
      </ion-card-title>
    </ion-card-content>

  </ion-card>

</ion-content>

正确的结果是: 正确显示卡片

但是当我尝试将这张卡嵌入ion-slides宽度时很奇怪。它在横向上看起来很好,看起来它有一些固定的宽度。我不知道如何让它在肖像中工作。代码在这里:

<ion-header>
   <ion-navbar>
      <ion-title style="text-align:center;">Title</ion-title>
   </ion-navbar>
</ion-header>
<ion-content class="tutorial-page">

  <ion-slides>
    <ion-slide>
      <ion-card>
        <ion-card-content>
          <ion-card-title style="color:#000000;text-align:center;padding-top:10px; font-size: 24px; font-weight: bold;">
            Title
          </ion-card-title>
        </ion-card-content>

      </ion-card>
    </ion-slide>
  </ion-slides>

</ion-content>

结果如下所示: 奇怪的宽度

这里的 CSS:

.tutorial-page {

  .toolbar-background {
    background: #fff;
    border-color: transparent;
  }

  .slide-zoom {
    width: 100%;
    height: 100%;
  }

  .slide-title {
    margin-top: 2.8rem;
  }

  .slide-image {
    max-height: 50%;
    max-width: 60%;
    margin: 18px 0;
  }

  b {
    font-weight: 500;
  }

  p {
    padding: 0 40px;
    font-size: 14px;
    line-height: 1.5;
    color: #60646B;

    b {
      color: #000000;
    }
  }

}

感谢我能得到的任何帮助,安德烈

4

1 回答 1

2

自己找到了解决方案...

我在一些css文件中有一些片段:

.swiper-container {
    width: 600px;
    height: 300px;
}

作为 Ionic 的初学者,我认为 css 文件与每个页面是分开的。所以我把这段代码放在其他页面上,显然影响了它。对 css 文件进行更改并不总是实时重新加载 UI。

于 2017-04-06T13:58:57.133 回答