HTML Input cursor position issue in Chrome when value is empty

前端 未结 8 1125
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 13:28

Just recently I have noticed out text inputs having a display issue in Google Chrome but only when the text is empty.

Notice how in the top image, when the input is

相关标签:
8条回答
  • 2020-12-13 14:01

    There is another hack that no one have mentioned as I can see. You could use a @media query to check out Chrome:

    @media screen and (-webkit-min-device-pixel-ratio: 0) {
        line-height: normal;
    }
    
    0 讨论(0)
  • 2020-12-13 14:04

    I encountered the similar issue. But I found it's better to use number for line-height instead of length(px, em or rem). Maybe using following code fix this problem:

    input[type="text"] {
      height: 46px;
      line-height: 1.1;
    }
    

    Plus, maybe the css above need to be paired with -webkit-appaearance: none for the desired rendering effect. Anyway, this works for me.

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