【问题标题】:Ion Slide Overflow离子载玻片溢出
【发布时间】:2020-05-29 20:30:25
【问题描述】:

我正在使用 ion-slide 并在放大和缩小第二张幻灯片上转换我的图像,但它在我的主幻灯片上溢出。

这是我的主要幻灯片,第二张幻灯片溢出了:

HTML:

<ion-content>
<ion-slides>
  <ion-slide class="slide-main">
    <ion-grid>
      <ion-row class="row-main">
        <img class="img-main" src="https://cdopromos.com/wp-content/uploads/2019/07/maxs-restaurant-chicken-all-you-can.jpg">
      </ion-row>
    </ion-grid>
  </ion-slide>
  <ion-slide class="slide-secondaruy">
    <ion-grid>
      <ion-row class="row-secondary">
        <img class="img-secondary" src="https://lh3.googleusercontent.com/proxy/iP2XG4WiD4Q2U18hRlCG9375ujydwARovLR8R6HrMLVp3iyH5pteC7RHOivfo3_njckHJyN21we1qmrbc7F3Bc2ao7UyCsMeMh6AGdt4v8loHSu51bHtOEC69e7HedDHrX3A9HRnKDg">
      </ion-row>
    </ion-grid>
  </ion-slide>
</ion-slides>
</ion-content>

CSS:

.row-main{
  height: 100vh;
  width: 100vw;
}

*{
  padding: 0;
}
.img-secondary{
  height: 100vh;
  transform: scale(1);
    animation: zoominout 30s infinite ;

}

.img-main{

}
.row-secondary{
  z-index: -1;
}
.swiper-slide{
  z-index: -1;

}

@keyframes zoominout {
  0% {
      transform: scale(1,1);
  }
  50% {
      transform: scale(1.2,1.2);
  }
  100% {
      transform: scale(1,1);
  }
}

.slide-main{
  z-index: 99;
}

我使用了 z-index 和 overflow-x:hidden 但什么也没发生

【问题讨论】:

    标签: ionic-framework ionic4 ion-slides


    【解决方案1】:

    我不确定是否有必要使用&lt;ion-grid&gt;,但如果您像这样构造模板代码,那么让&lt;ion-slide&gt; 中的默认布局来构造您的内容。

    html

    <ion-content>
      <ion-slides>
        <ion-slide class="slide-main">
          <img class="img-main" src="https://cdopromos.com/wp-content/uploads/2019/07/maxs-restaurant-chicken-all-you-can.jpg">
        </ion-slide>
        <ion-slide class="slide-secondary">
          <img class="img-secondary" src="https://images.pexels.com/photos/2397361/pexels-photo-2397361.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500">
        </ion-slide>
      </ion-slides>
    </ion-content>
    

    在组件的scss 中继续告诉&lt;ion-slide&gt; 隐藏其包含边界之外的任何内容。

    /**
    Add this to your scss
     */
    ion-slide {
      overflow-x: hidden!important; // or overflow: hidden or overflow-y: hidden
    }
    /**
    Add this to your scss
     */
    
    .row-main{
      height: 100vh;
      width: 100vw;
    }
    
    *{
      padding: 0;
    }
    .img-secondary{
      height: 100vh;
      transform: scale(1);
      animation: zoominout 30s infinite ;
    
    }
    
    .img-main{
    
    }
    .row-secondary{
      z-index: -1;
    }
    .swiper-slide{
      z-index: -1;
    
    }
    
    @keyframes zoominout {
      0% {
        transform: scale(1,1);
      }
      50% {
        transform: scale(1.2,1.2);
      }
      100% {
        transform: scale(1,1);
      }
    }
    
    .slide-main{
      z-index: 99;
    }
    

    最终结果看起来像this

    【讨论】:

      猜你喜欢
      • 2020-10-09
      • 1970-01-01
      • 1970-01-01
      • 2016-11-17
      • 1970-01-01
      • 2020-11-22
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多