我有一个ionic app
,并且我使用 ion-slides 指令,该指令使用 swiper 滑块,用于图像滑块。这是它在视图中的外观:
<ion-slides ng-if="slider.length > 0 && article.external_media.length < 1" class="slides">
<ion-slide-page ng-repeat="item in slider">
<img ng-if="item.image" ng-src="{{ fileServer }}/imagecache/cover/{{ item.image }}" class="cover">
</ion-slide-page>
</ion-slides>
这是它的CSS:
.slider {
&:after {
content: "";
display: block;
position: absolute;
width: 200%;
height: 100%;
box-shadow: 0px 1.5rem 4.8rem 3rem rgba(0, 0, 0, 0.4) inset;
bottom: 5px;
left: -50%;
}
}
.cover {
width:100%;
position: relative;
&:after {
content: "";
display: block;
position: absolute;
width: 200%;
height: 100%;
box-shadow: 0px -5rem 4.8rem 3rem rgba(0, 0, 0, 0.4) inset;
bottom: 5px;
left: -50%;
}
}
.slides {
height: 325px;
}
问题是如果不给slides
类指定任何高度或将其设置为100%
or auto
,则图像不可见,因为未设置高度。当我确实为 设置了高度时slides
,它们无法正确调整大小,因为设置了高度,并且图像水平拉伸然后在更大的屏幕上。我该如何解决?