无法将图像置于ion-slides中心

3

我正在尝试设计一个ion item内的幻灯片,一切都正常,但是幻灯片内的图片没有居中显示。

<ion-item style="height:45%; padding-left: 0;">
  <ion-slides centeredSlides="true" zoom="true" class="image-slider" loop="true" slidesPerView="1">
    <ion-slide *ngFor="let img of images">
      <img style="max-width:100%; text-align: center; max-height:100%;" src="{{img}}" class="thumb-img" imageViewer/>
    </ion-slide>
  </ion-slides>
</ion-item>

在我的ts文件中,我有一个URL数组

    images =[   'https://pay.google.com/about/static/images/social/knowledge_graph_logo.png',
            'https://connectnigeria.com/articles/wp-content/uploads/2018/05/google-apps.jpg',
            'http://www.google.com/logos/doodles/2015/tu-bav-2015-5651988540817408-hp2x.jpg'
        ];

当我这样做时,我的左侧会出现一个空白的空间,我想将图像放置在中心并与滑动ui一起。

enter image description here

1个回答

1

ion-slides.image-slider {
    display: flex;
    justify-content: center;
    align-items: center;
}
  <ion-item  style="height:45%; padding-left: 0;">
        <ion-slides centeredSlides="true" zoom="true" class="image-slider" loop="true" slidesPerView="1">
            <ion-slide  *ngFor="let img of images">
                    <img style="max-width:100%; text-align: center; max-height:100%;"  src=https://image.ibb.co/k303BL/111.jpg class="thumb-img" imageViewer/>
            </ion-slide>
   </ion-slides>
</ion-item>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接