[英]Fit ion-card to child image in ionic swiper
我在 Ionic 應用程序中使用 swiperJs 框架。 在這個組件中,使用滑動圖像,我需要離子卡正好適合圖像寬度。
<ion-card>
<swiper class="horizontal-swiper" [config]="imageSwiperConfig">
<ng-template swiperSlide *ngFor="let image of images">
<img class="full-screen-image" src="./assets/{{image}}">
</ng-template>
</swiper>
</ion-card>
ion-card {
border-radius: 2%;
margin: auto;
height: 100%;
}
.horizontal-swiper {
height: 100%;
}
.full-screen-image {
height: 100%;
width: auto;
}
public imageSwiperConfig: SwiperOptions = {
slidesPerView: 'auto',
preloadImages: true,
pagination: true,
嘗試將 class .full-screen-image
更改為如下所示
.full-screen-image {
height: 100%;
width: 100%;
object-fit: cover;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.