On my website, I have circular images implemented using the Bootstrap 4 class rounded-circle
. While they appear perfectly round on desktop, they become oval-shaped on mobile devices such as the iPhone XR. You can see the issue in this Codepen link.
Here is how they look on desktop:
https://i.sstatic.net/0C8Z0.png
And here is how they appear on mobile:
https://i.sstatic.net/Di6RX.jpg
Below is the code snippet I am using:
<div class="nh-service-card-image-wrapper">
<img src="images/guitar.jpg" alt="Reebit" class="img-fluid rounded-circle"
width="85" height="85">
</div>
.nh-service-card-image-wrapper {
aspect-ratio: 1;
}
.nh-service-card-img img {
object-fit: cover;
width: 90% !important;
height: 90% !important;
margin-top: 1.2em;
}
Please note that the width="85"
and height="85"
attributes in the img
tag are necessary for the technology I am using.