【问题标题】:How to make ion-slides images all the same height?如何使离子幻灯片图像高度相同?
【发布时间】:2018-09-19 00:55:55
【问题描述】:

我尝试在 ionic 3 中制作方形组件幻灯片,但有 2 张图片比其他图片大。我怎样才能让它们都一样高?

<ion-slides *ngIf="ads && ads.length" autoplay="500" loop="true" speed="300">
  <ion-slide   *ngFor="let ad of ads">
    <img src="{{ad.img}}" />
  </ion-slide>
</ion-slides>

This is the "normal size"

this one is too big and i need to make it smaller

【问题讨论】:

    标签: angular typescript ionic3


    【解决方案1】:

    您可以为您的 img 标签创建一个类并根据需要设置高度的像素,还可以添加 object—fit: cover 以使图像不中断

    【讨论】:

    • 你确定吗?因为如果您输入例如:img { height: 250px !important} 图像必须采用该高度。也许你有一些覆盖 img 元素的类,检查一下。另外检查 ion-slide 和 ion-slides 的类,也许是一些高度设置它。
    • 好的,但现在较长的图像旁边有空白区域。对象拟合有问题
    • 对象适合保留您在图像中设置的宽度和高度,它仅调整大小以适合容器。尝试将宽度设置为高度,并根据需要使用该值。例如尝试宽度 100% !important 在图像及其父项上。
    猜你喜欢
    • 2019-11-18
    • 1970-01-01
    • 2015-05-12
    • 2018-08-17
    • 2013-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    相关资源
    最近更新 更多