Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to keep image quality when img element using transform in css?

When I rotate image with using CSS transform, image is going to low quality.can I keep image quality after image rotated only using CSS?

.rotate {
       margin-right: 100px;
  -webkit-transform: translate(2px, 1px) rotate(5deg);
          transform: translate(2px, 1px) rotate(5deg);
}
<div>
  <img src="https://i.sstatic.net/dAjV9.jpg" title="source: imgur.com" class="rotate"/>


  <img src="https://i.sstatic.net/dAjV9.jpg" title="source: imgur.com" />
</div>
</br></br>
<div>
    <img src="https://i.sstatic.net/e3NdJ.jpg" title="source: imgur.com" class="rotate" width="150px" height="150px"/>


  <img src="https://i.sstatic.net/e3NdJ.jpg" title="source: imgur.com" width="150px" height="150px"/>
</div>
like image 253
lwinkyawmyat Avatar asked Feb 14 '26 09:02

lwinkyawmyat


1 Answers

This is an anti aliasing issue of the browser.You can add -webkit-backface-visibility: hidden; to the element being rotated which triggers antialiasing on the element.

like image 132
Tushar Avatar answered Feb 17 '26 04:02

Tushar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!