Hovering over CSS transition in Safari lightens certain font color

后端 未结 7 1393
北恋
北恋 2020-12-13 14:56

In my CSS I defined a transition for a class. For some reason, when I hover over the class with the transition, the transition-duration for some reason alters t

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 15:16

    I can't begin to tell you why it's doing this, but Safari isn't changing your text color, it's anti-aliasing the text differently while the transition is in motion. The text edges get smoother, and the text itself becomes thinner. This is extra obvious if you zoom in on the fiddle with accessibility tools. At some smaller sizes, the shading around the button next to the form text shifts too. (Is it possible that Safari is redrawing some things, or reorienting them on a sub-pixel level during the transitions ? Somebody explain this please, it's driving me nuts now!)

    Because I have no real idea why it's doing this either, these might not be the best solutions:

    Depending on what you're transforming, replacing the css transform with a javascript animation will probably fix it.
    For example in your fiddle, the problem also occurred with a scale transformation, but not with a similar jQuery animate function.

    There seem to be some shades and styles where the anti-aliasing change is less obvious (at least in the fiddle), so you could also try styling the placeholders and other effected text differently.
    (This thread may help with styling the placeholders, if you go that route: Change an HTML5 input's placeholder color with CSS )

提交回复
热议问题