CSS Transforms - Why does a simple rotation make t

2020-03-01 18:59发布

Why does a simple rotate make an image blurry?

Looking to rotate an image 90deg, but the resulting image is unacceptably blurry.

transform: rotate(90deg);

This is the same in both Firefox and Chrome (haven't checked other browsers).

Here is a JSFiddle link:

http://jsfiddle.net/6d2GT/1/

Are there any workarounds/tricks to minimize the blurring?

--

In case it's computer specific, an image link http://i.imgur.com/WzXkRL9.png

4条回答
混吃等死
2楼-- · 2020-03-01 19:09

Adding a scale transform,

scale(0.99)

seems to help

http://jsfiddle.net/jetRed/6d2GT/3/

查看更多
该账号已被封号
3楼-- · 2020-03-01 19:10

You could use the following :

#pic {
  -webkit-transform: rotate(90deg) translatez(0);
  transform: rotate(90deg) translatez(0);
  margin-top: 50px;
  -webkit-transform-origin: 50%  51%;
}

An example: http://jsfiddle.net/6d2GT/2/

don't forget the needed prefixes

查看更多
一夜七次
4楼-- · 2020-03-01 19:17

You must put the image inside another tag and rotate the parent tag. This way the image doesn't appear blur.

HTML

<div class = "rotate_parent">
    <img ...>
</div>

CSS

.rotate_parent{
    transform: rotate(90deg);
}
查看更多
Deceive 欺骗
5楼-- · 2020-03-01 19:32

The answer is simple!!! You need to make sure your images width and height are even numbers. You don't need to worry about adding the rotation to the parent, you can apply it directly to the image.

I had the problem just now and the first thing I thought of as it seemed to be fine rotating 180 was that as it rotates 90 it's not aligning correctly due to the odd number of pixels. So it tries to center which in turn causes a blur effect.

查看更多
登录 后发表回答