1
1
109k42021-01-26 16:43:56
css
109k4, 2021-01-26 16:43:56

How to fix image rendering issues?

Images are blurry, and when the height is greater than the width, they are stretched. It happens on Chrome, Opera, Edge, on Firefox, everything is perfect.

Chrome, Opera, Edge

60101a29ecd85608820684.png

Firefox

60101a3e2da98467456422.png

html

<div class="userIcon">
  <img src="someUrl" alt="">
</div>


scss

.userIcon {
    width: 50px;
    height: 50px;

    border-radius: 50%;
    background-color: darken($base-color, 30%);

    overflow: hidden;


    img{
      width: 100%;
      height: 100%;

      object-fit: cover;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2021-01-26
@109k4

Try like this

.userIcon {
    width: 50px;
    height: 50px;

    border-radius: 50%;
    background-color: darken($base-color, 30%);

    overflow: hidden;

    display:flex;

    img{
      margin: auto;
      max-width: 100%;
      max-height: 100%;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question