Webkit-based blurry/distorted text post-animation

2019-01-04 07:47发布

This issue appears to affect all WebKit-based browsers, including the iPhone.

First some background. The site I'm working on uses a JavaScript-based 'slider' animation that is basically identical to this: http://www.assistly.com/product-tour/#/easy-setup

The only difference is that I'm using -webkit-transform: translate3d to 'power' the actual animation. When using this method, as opposed to a JavaScript-based method, the text becomes all blurry once the content has been animated. This is especially noticeable on the iPhone.

A few workarounds I saw were to remove an relative positioning, which I did, and to add a rule for -webkit-font-smoothing: antialiased, which I also did. Neither change made the slightest difference.

The only way I could make this work properly without blurry text was to use regular JavaScript for the animation and bypass the translate3d altogether. I'd prefer to use translate3d because it performs much faster on WebKit-enabled devices, but for the life of me I cannot figure out why it is affecting the text in such a poor way.

Any suggestions or solutions would be greatly appreciated.

16条回答
放荡不羁爱自由
2楼-- · 2019-01-04 08:28

None of these answers worked for me but using

display: inline-table;

did the trick

查看更多
SAY GOODBYE
3楼-- · 2019-01-04 08:28

I also had same issue when i used translateZ, it got resolved when i used translateX and translateY together and not translateZ , like this

transform: translateX(-50%) translateY(-50%);

works with transparent background as well, dont know the reason how it worked but worked

查看更多
疯言疯语
4楼-- · 2019-01-04 08:29

Solution found in my case was setting a height value of the first child element

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-01-04 08:31

@kizu These answers and suggestions do not help. For your jsfiddle you need to add

-webkit-perspective-origin: 50% 50%; -webkit-perspective: 1400px;

to the parent element of the element you want to use translate3d on, otherwise translating the z-axis doesn't actually do anything. In this case you are applying it to the button you click, I think you meant to apply it to the content.

But anyway, adding those to activate z-axis change causes the blur to the button in your example.

I would love to find a solution to this as well, I fear there isn't one.

查看更多
Ridiculous、
6楼-- · 2019-01-04 08:32

As @Robert mentioned above, sometimes adding background helps, but not always.

So, for the example Dmitry added that's not the only thing you must do: except from the background, you must tell browser to explicitly use the proper anti-aliasing, so, there is a fixed Dmitry's example: http://jsfiddle.net/PtDVF/1/

You need to add these styles around (or for the) blocks where you need to fix the anti-aliasing:

background: #FFF; /* Or the actual color of your background/applied image */
-webkit-font-smoothing: subpixel-antialiased;
查看更多
趁早两清
7楼-- · 2019-01-04 08:32

This is the best solution translateX(calc(-50% + 0.5px))

查看更多
登录 后发表回答