My current progress stuck at something like this. I need help
I need the picture in the ion-img to fill its container without losing its aspect. here is my html code
<ion-col class='left-content'>
<ion-img [src]='voucher.image'></ion-img>
</ion-col>
here is my scss code
ion-img {
min-width: 5.7em;
min-height: 5.7em;
border-radius: 0.5em;
@include my-img-shadow();
}
.left-content {
padding-top: 0.8em;
position: absolute;
left: 0.5em;
}
By setting the width property to 100%, you are telling the image to take up all the horizontal space that is available. With the height property set to auto, your image's height changes proportionally with the width to ensure the aspect ratio is maintained. The end result is an image that scales up or down perfectly.
In the Select Picture dialog box, locate the folder that contains the picture that you want to insert, select the picture file, and then click Insert. To maintain your picture's proportions (to prevent distortion) when it is inserted into the shape, check the Lock picture aspect ratio box, and then click OK.
To auto-resize an image or a video to fit in a div container use object-fit property. It is used to specify how an image or video fits in the container. object-fit property: This property is used to specify how an image or video resize and fit the container.
The CSS object-fit property is used to specify how an <img> or <video> should be resized to fit its container. This property tells the content to fill the container in a variety of ways; such as "preserve that aspect ratio" or "stretch up and take up as much space as possible".
Use object-fit:cover
.
ion-img {
...
object-fit:cover;
}
.ion-img {
height: 100%;
width: 100%;
object-fit:cover;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With