Font-Weight CSS Transition in Chrome

前端 未结 7 2027
生来不讨喜
生来不讨喜 2020-12-06 04:28

Trying to get font-weight to gracefully transition from \'400\' to \'600\' using CSS but it doesn\'t appear to be working in Chrome. Is this a known bug or am

相关标签:
7条回答
  • 2020-12-06 05:08

    I've tweaked @Idra's fiddle to make the normal to bold transition a bit smoother. Here's the fiddle: http://jsfiddle.net/y7rLwx95/

    Changes... Since the text width will get wider when going to bold, I've added an initial "stretch" transition by increasing the letter spacing:

    .element:hover {
       letter-spacing: 0.9px;
       transition: all .3s linear;
    }
    

    Then delayed the fading in of the bold ::before element:

    .element:hover::before {
       opacity: 1;
       transition-delay: .2s
    }
    

    Also some additional tweaks here:

    .element::before {
       transition: all .3s linear;  /* replace */
       letter-spacing: 0;           /* additional */
    }
    

    The transition timing is just whatever feels right to me. The original idea @Idra posted is significant to me. I accept that fact that the widths should be different between normal and bold, as that's the intent of different font weights. So really the challenge, IMHO, is to figure out how to go between the 2 looks in a smooth, no jarring way. This seems to be the best solution so far I've found.

    0 讨论(0)
提交回复
热议问题