I need to add border-radius
to ion-img
but it seems shadow DOM
won't let me modify.
HTML
<ion-img [src]="img-url" [alt]="alt"></ion-img>
CSS
ion-img {
border-radius: 10px !important;
}
The correct, non-obvious, way to do this is with CSS shadow parts.
In this case ion-img has a shadow part image
so our SCSS looks like:
ion-img::part(image) {
border-radius: 10px;
}
Yes, the part has no quotes and is the full word "image" (not "img" we need the part name, not the target tag name).
HTML
<ion-img [src]="img-url" class="your-img"></ion-img>
CSS
.your-img {
border-radius: 10px !important;
overflow: hidden;
}
<ion-card>
<ion-img src="imag"></ion-img>
</ion-card>
after that set the style of the image
set image with and heigth to 100% in ion-img
style
modify the value of radius in the ion-card component
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